Commit Graph
4 Commits
Author SHA1 Message Date
dotCooCoo bc5b1f3229 Correct module namespace bindings and export resolution limits 2026-11-26 13:29:17 -08:00
dotCooCoo 9281751e6f Bound module linking and count only active execution frames 2026-11-26 11:59:49 -08:00
dotCooCoo 4cfa6a8434 JavaScript: module namespaces, global deletes and module loading follow ES2015
- A read or write that reaches a module namespace through a prototype
  chain checks the export's temporal dead zone and refuses the write;
  for-in over a namespace lists its keys without reading the exports.
- `delete this.x` and a delete inside `with` remove only the property,
  so a later `let x` is still a SyntaxError.
- An arrow function's `length` is configurable.
- `let [` cannot start the body of if, else, while, for or a label.
- A specifier with an unpaired surrogate parses; the loader refuses it
  before reading any file.
- Each module's code counts against the heap from when it loads, and
  export lookups use an index instead of copying export lists.
- A module reached again through another path is not read or counted
  against the 32 MiB source limit again, its relative imports are read
  from the folder the file is in, and on Windows two files whose names
  differ only in case in a case-sensitive folder stay two modules.
- `$.evalFile` in a module reads beside that module.
- `script.run` takes `module`, and a `.mjs` file picked on the web runs
  as a module.
- Without `es2015`, the compiler does not collect the block scopes that
  only Annex B block functions read.
- The test262 runner grades negative module tests by their phase and
  counts panics on their own.
2026-11-22 15:54:53 -08:00
dotCooCoo 7615aed3ee JavaScript: a .mjs script runs as an ECMAScript 2015 module
script.run, File > Scripts and Other Script... run a file ending in .mjs as a
module: strict code with import and export declarations at its top level.
parse_module reads the module grammar and its early errors, and
Realm::start_module and Realm::run_module load the module graph through the
host, link every import before any module runs, and run each module once,
after the modules it imports. Imports read the exporting binding each time;
a read before initialization is a ReferenceError and an assignment is a
TypeError. import * as ns gives a namespace object that is not extensible,
and Object.isSealed and Object.isFrozen on it throw a ReferenceError for an
export its module has not initialized.

Specifiers are ./ and ../ paths to .mjs and .js files, resolved against the
importing file and read only through the script's file scope, so a module
can import only from the script's folder and the folders below it. Bare
names, URLs and absolute paths are a SyntaxError that names the specifier.
Module files count against the #include limits: 64 files besides the
script, 16 imports deep. import and export stay syntax errors in .js and
.jsx scripts; import() is not read. script.listInstalled lists .mjs files.

The test262 runner also runs the module tests under language/module-code,
import and export, reading the fixture files they import from the suite.
2026-11-22 12:16:11 -08:00