Several tests returned early when the code under test gave back nothing,
so the regression they guard against passed. Each of those guards now
checks only what the host provides (an installed face, the bundled
fonts), and the output itself is asserted:
- PDF live text: the lam-alef face is no longer picked by whether its
type imports (#6072); Insert Kashidas asserts the kashida and the
imported type.
- Effects and Expand Appearance on type assert the outlines and the
drawn type when the default face is installed.
- The OpenType panel's Stylistic Sets test asserts sets with the
bundled fonts.
- Thumbnail worker tests assert that the worker starts; the memory
peak test asserts a reading.
- The json2 test checks the interpreter's Date, replace and RegExp on
every run, before looking for json2.js.
- Devanagari arrow keys and the Arabic narrow-area wrap assert the
layout they set up.
Async function activations now save and restore this_in_env, strict_class, new_target and this_env with main's Frame fields. The string spread test sets its fuel above what main's iterator-based spread takes.
Proxies join main's construct path in class_ops.rs: new and Reflect.construct both run the construct trap there, with new.target passed through. A Symbol-key lookup passes through a proxy to its target, so spread and for-of read a proxy of an array with the array iterator.
main added `Value::Symbol`, a binary_octal argument to `string_to_number` and its own
ES2015_BUILT_INS and ES2015_FEATURES in the test262 runner.
- A Map or Set key compares a Symbol by identity, as SameValueZero does.
- CanonicalNumericIndexString reads a typed array property name with the ES2015 ToNumber.
- The collection and binary-data test262 runner uses ES2015_COLLECTION_BUILT_INS and
ES2015_COLLECTION_FEATURES, writes its failures to `es2015-builtins-failures.txt` so it does
not overwrite the ES2015 subset's `es2015-failures.txt`, and runs each test through `run_one`.
runs_strings_as_code matched a string token naming eval, Function or
constructor, but not a template, so this[`eval`](`new Map()`) did not
skip when Map is missing. Templates now match the same names, as
needs_missing_builtin_in already reads both forms.
- `async (...xs,) => xs` is a SyntaxError, as `(...xs,) => xs` is.
`async (x,) => x` still parses.
- An arrow function's parameters may end with a comma: `(a, b,) => a + b`
parses, and `(a,)` without `=>` is still a SyntaxError.
- A `var` that an inherited property of the global object declared,
without ECMAScript 2015 scoping, no longer stops a later `let` of its
name once the realm turns the option on.
- A tagged template's object reserves the heap for its index names and its
`raw` property before it is made.
- The test262 runner skips a test whose template literal runs a missing
built-in as code, as it skips one whose string does.
The engine built Boolean.prototype but defined no global Boolean, so
Boolean(x), new Boolean(x), x instanceof Boolean and filter(Boolean)
threw a ReferenceError. Boolean now converts a value when called and
makes a Boolean object with new (ECMA-262 5.1 sections 15.6.1 and
15.6.2), with Boolean.prototype as its prototype.
test262 no longer skips tests that name Boolean, so more of them run;
docs/target-app-parity.md has the new counts.
[[GetProperty]] and the for-in recheck kept a root for every prototype a
getPrototypeOf trap gave, until the whole walk ended, so a chain of
fresh proxies could reach the heap limit. Each walk now holds one root
slot and replaces it at each hop.
- A function a legacy run declares on the global object stays a root
while declaring it runs a proxy's traps on the global object's
prototype chain; a collection in a trap freed it before.
- Proxy and Reflect become globals after their functions are added, so
an install that stops part way leaves no global without them.
- The test262 Proxy and Reflect and ES2015 runners name each run that
panicked, with or without Options::es2015, its test path and mode.
- 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.
- A block function in script or eval code no longer stops the run with
"redeclaration of" when a `let`, a `const` or a block function between
the code and its variable environment has its name, or when the global
object cannot take the variable (Annex B.3.3.2 and B.3.3.3). Its block
still has the function, and a `var` of the name is still a SyntaxError.
- A script stopped by the heap limit or the frame limit declares none of
its `let` and `const` names, so a later script can declare them. The
frame limit is checked, and the heap reserved for the names, before
anything is declared.
- An arrow function in an async arrow function's parameters reads `await`
as an identifier, as its own body does.
- With E4X, `async::name` is a qualified name.
- `AsyncFunction` inherits from the built-in `Function` even after a
script replaced `Function.prototype.constructor`.
- The test262 reports list the older edition's panics, an async test
passes only when one `print` call gives exactly the completion line,
and the promise collection test checks that all 200 rejections arrive.
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.
Conflicts were resolved by keeping both sides:
- The compiler keeps the base branch's `declared_function` and its block
function names, and `list_scope` also declares class names.
- Global and eval code keep their environments and code reachable through
`instantiate_global`, and declarations check functions before variables
with `check_global_functions` and `check_global_vars`.
- A call's frame keeps `new.target` and the class bindings, and its heap
reservation counts the class code's hidden bindings.
- Spread reads `String` objects and an array's length as the base branch
does, and keeps its list of elements counted until the elements are the
array's properties. A string's characters are counted only until the
elements are reachable from the roots, so a collection does not count
them twice.
A realm made with Options::es2015 has Proxy, with Proxy.revocable, and
Reflect with its thirteen functions (ECMA-262 11th edition, sections
9.5, 26.1 and 26.2), with string property names. Every internal method
of an object goes through one dispatch, so a proxy's traps run for
property reads and writes, in, delete, for-in, the Object functions,
instanceof, calls and new, and when the proxy is a prototype or a with
object. Array.isArray, concat and JSON.stringify treat a proxy of an
array as an array.
- Each trap result is checked against the target's invariants, and a
violation or an operation on a revoked proxy throws a TypeError.
- Traps take fuel and count against the limit on nested calls.
- A proxy given to a host function throws a TypeError naming the
argument, without running its traps.
- Reflect.construct gives a built-in's result the prototype of
newTarget, and Object with a different newTarget makes a new object.
- for-in skips a name deleted or made non-enumerable during the loop,
and does not ask a has trap.
- Descriptor values a trap returns stay rooted while they are read.
script.run gives a .js file both globals; a .jsx file and a source
string have neither. cargo xtask test262 runs the suite's Proxy and
Reflect tests whose features are present.
Docs: docs/mcp.md, docs/target-app-parity.md.
- Spreading an array checks the room in the result as each element is
read, so a getter that shrinks an array of length 4294967295 gives the
elements it reads. An array no getter reads, and any other object, is
still checked against its length when spread begins.
- Spread counts each element's index name, and each character of a
string, against the heap as it reads them.
- A function with default or rest parameters checks the heap again before
its body's environment and declarations are made, since the parameters'
values may have used the room the call reserved.
- Without the ES2015 option, a function that eval code declares on the
global object closes over the global scope, so it sees the scripts'
`let` and `const` names, as functions of global code do.
- With the ES2015 option, a global `var` whose name the global object
only inherits gets its own property.
- The test262 ES2015 subset runs a test whose source does not tokenize,
so the error counts as a failure instead of a skip.
A .js script now reads async function declarations and expressions, async
arrow functions and async methods in object literals, as ECMA-262 2017
section 25.5 defines them. A call returns a Promise that the function's
return resolves and an uncaught exception rejects. await suspends the
function's frame until its operand settles; a promise job resumes it with
the value, or throws the rejection at the await, so try, catch and finally
work around it.
- Options::es2017 turns the syntax on and implies Options::es2015;
script.run sets it for .js files. .jsx scripts and source strings keep
async and await as plain names.
- A suspended frame is a heap object the collector traces, reached only
from its promise reactions, so a function waiting on a promise that
nothing can settle is freed. Each resume is a job and takes fuel.
- AsyncFunction and its prototype exist without a global binding; async
functions are not constructors and have no prototype property.
- The test262 runner reads the async-function, await and async-arrow
folders and counts runs with and without the option; an async test with
a runtime negative now has to throw.
A realm made with Options::es2015 reads function* declarations and
expressions, *name() methods in object literals, yield and yield*, as
ECMA-262 11th edition sections 14.4 and 25.4 define them. A suspended
generator keeps its frame in its object; next, return and throw on
%GeneratorPrototype% push it back on the interpreter's frame stack, so
a resumption takes fuel and counts against the frame limit, and return
runs the finally blocks around the yield. Resuming a running generator
throws a TypeError. yield* passes next, throw and return on to its
iterator and closes one without throw before throwing a TypeError.
%GeneratorFunction% is reached through a generator function's
constructor. Outside generators, sloppy code still reads yield as a
name, and a realm without the option reads function* as a syntax error.
An engine that #targetengine kept from a .jsx run has no generator
built-ins, so a generator function called there throws a TypeError.
cargo xtask test262 runs the generator folders: 509 of 549 runs pass
(94 of 96 before). Docs: docs/mcp.md, docs/target-app-parity.md.
- A promise resolved with itself roots its TypeError before the queue
reserves room, so a collection there no longer frees the reason.
- A sliced run whose last job ends a slice reports Done in that slice
instead of Paused, and a pause asked for in a run's last step no longer
pauses the next run.
- The job queue is replaced at run end, which frees its buffer.
- A reaction job runs a finally callback as its own call, so a slice can
pause inside it; the callback no longer runs to its end within the
unbroken-fuel allowance.
- all, allSettled and race read an array to its current length at each
step, and a string input is flattened through the charged path and
shared instead of copied.
- The test262 runner checks the expected exception of an async test with
a runtime negative.
With Options::es2015, vectorcraft-js reads and runs two ECMAScript 2020
forms: optional chains (a?.b, a?.[key], f?.(args) and the accesses and
calls after them) and ??.
- An optional step that finds undefined or null ends the whole chain
with undefined, without evaluating its other keys and arguments.
Parentheses end a chain. a?.b() and a.b?.() call with a as this,
(a?.b)() does too, eval?.(code) is an indirect eval, and delete a?.b
is true when a is undefined or null.
- ?? keeps any left side other than undefined and null.
- ?. before a digit still reads as ? and a number (a?.5:1).
- Mixing ?? with && or || without parentheses, assigning to or updating
an optional chain, a tagged template after one and new a?.b() are
syntax errors.
Two new jump instructions test for undefined and null, and the verifier
checks both of their paths. A chain of any length compiles with a loop.
.jsx files and source strings stay ES5.1, where ?. and ?? are syntax
errors.
The test262 ES2015 subset now also reads expressions/optional-chaining
and expressions/coalesce: 426 of 426 negative parse runs and 591 of 615
other runs pass with the option. The 24 failing runs are the same as
before this change.
With Options::es2015, vectorcraft-js reads and runs ECMAScript 2015
classes: declarations, scoped to their block like let, and
expressions, with extends, static members, getters and setters and
computed method names. Class code is strict mode code, methods are
not enumerable and cannot be constructed, and calling a class without
new throws a TypeError.
A derived constructor's this throws a ReferenceError until super(...)
returns, and its default constructor passes its arguments on.
super.name and super[key] read, call and write through the prototype
of the method's home object, in class methods and in object literal
methods, which ES2015 allows in a .js script. new.target names the
constructor new was applied to, in functions and their arrow
functions. A class can extend null, a function, a class, or the
built-in constructors Object, Function, Array, String, Number,
Boolean, RegExp, Date and the error types; extending any other
built-in throws a TypeError. Each class and method takes fuel and
counts against the heap limit, and deep constructor chains stop at
the frame limit. A .jsx file and a source string stay ES5.1, where
class syntax is a SyntaxError.
The test262 runner adds the class, super and new.target tests to its
ES2015 subset (1,125 tests). With the option, 554 of 554 negative
parse runs and 1,527 of 1,633 other runs pass; the failing runs use
Object.setPrototypeOf, RegExp.prototype.flags, function name
properties, a configurable length, the caller and arguments
restrictions, or super and new.target in direct eval.
Docs: docs/mcp.md, docs/target-app-parity.md.
With Options::es2015 set, a vectorcraft-js realm has Symbol (ECMA-262
11th edition, section 19.4): Symbol(description), which new refuses,
the description getter, toString, valueOf, and Symbol.for and
Symbol.keyFor over a registry that lasts as long as the realm. typeof
gives "symbol". Symbols are property keys: Object.getOwnPropertySymbols
lists them in the order they were added, defineProperty,
getOwnPropertyDescriptor, freeze, seal, in, delete and hasOwnProperty
take them, and for-in, Object.keys, getOwnPropertyNames and
JSON.stringify leave them out. String(symbol) and symbol.toString()
give Symbol(description); any other conversion of a Symbol to a string
or a number throws a TypeError.
Symbol.iterator, asyncIterator, hasInstance, toPrimitive and
toStringTag are defined. Conversion to a primitive calls @@toPrimitive,
instanceof calls @@hasInstance, and Object.prototype.toString writes a
string @@toStringTag. Array.prototype.values (also @@iterator), keys
and entries, String.prototype[@@iterator] (by code point) and every
arguments object's @@iterator return iterators with next(). An Array
Iterator's next keeps its object reachable while a length getter or
valueOf runs script.
Each iterator step takes fuel, and each Symbol and registry entry
counts against the heap limit. An error about a Symbol-keyed property
names the Symbol by at most 256 units of its description, built only
when the error is thrown. String(symbol), symbol.toString() and the
[object tag] of Object.prototype.toString charge their copies to the
heap and fuel first. Realms without the option, including the one the
app runs scripts in, are unchanged. for-of, spread and destructuring
are not part of this change.
cargo xtask test262 runs the suite's Symbol, ArrayIteratorPrototype,
StringIteratorPrototype, getOwnPropertySymbols, Array.prototype
values/keys/entries/Symbol.iterator and String.prototype[Symbol.iterator]
tests in such a realm: 164 of 216 runs pass (6 before). The 52 others
expect a configurable function length and a function name property.
A script run from a .js file now has Promise as ECMA-262 11th edition
section 25.6 defines it: the constructor, then, catch, finally, and
Promise.resolve, reject, all, allSettled and race. .jsx scripts and
scripts given as source keep the ES5.1 built-ins; a named engine gets
Promise at the first .js run that names it and keeps it.
- The callbacks run as jobs from one FIFO queue after the script's own
code ends and before the run ends, sliced like the script, with no
native recursion along a then chain. Each job takes 1 unit of fuel, so
an endless chain stops at the fuel limit.
- More than 1,048,576 waiting jobs end the run with a Jobs limit error.
A run that fails, hits a limit or is stopped drops its waiting jobs
and rolls back as before.
- A promise still rejected with no handler when the run ends goes to
the report's unhandledRejections (first 20) and unhandledRejectionCount,
and to the Script Console with its file, line and column.
- Until the language has iterators, all, allSettled and race take
arrays, objects with a whole-number length and strings, and the
statics always build plain Promise objects. Promise.any is not provided.
cargo xtask test262 now runs the suite's built-ins/Promise tests that
need only the built-ins present: 402 of 538 runs pass.
Docs: docs/mcp.md, docs/target-app-parity.md.
A realm with Options::es2015 now has Map, Set, WeakMap and WeakSet, and
ArrayBuffer, DataView and the nine typed arrays from Int8Array to
Float64Array with %TypedArray%.from, of and the prototype methods
(ECMA-262 6th edition, sections 22.2 to 24.2). A realm without the
option, the ExtendScript realm included, has none of these names.
- Map and Set compare keys with SameValueZero and keep insertion order.
forEach and iterators skip entries deleted before they reach them and
visit entries added during the walk; the collector removes holes and
moves live iterators.
- WeakMap and WeakSet hold their keys weakly. The collector marks a
WeakMap value only once its key is reachable another way and drops the
entries of unreachable keys, also when a value refers to its key.
- Typed arrays store elements little-endian; DataView is big-endian
unless littleEndian is true. Numeric property names are elements or
nothing, with the element descriptors of later editions. Copies to the
same element type keep every bit.
- An ArrayBuffer longer than 2^32 - 1 bytes or than the heap limit is a
RangeError before anything is allocated, and every element a method
visits takes fuel.
- Until the language has iterators, the collection constructors and
%TypedArray%.from read an array, a string by code point or an object
with a length, by index. A typed array constructor reads an array or
an object with a length the same way, and converts a first argument
that is not an object to a length.
- The %TypedArray%.prototype methods that share an Array method use the
element count, and an Array method called on a typed array reads its
length property. Array methods visit every element of a typed array
longer than 4,096.
- Check Script counts new of these constructors as the language's.
test262 runs the Map, Set, WeakMap, WeakSet, ArrayBuffer, DataView,
TypedArray and TypedArrayConstructors folders in ES2015 realms.
Docs: docs/mcp.md, docs/target-app-parity.md.