ECMA-262 in Lean

From the overlay: spec/formal/readings.emu, spec/formal/errata.txt

Errata

The places where the overlay reads the text of ECMA-262 in more than one way: 36 defects of the text and 2 proposed normative changes, from spec/formal/readings.emu. For each, the sentences it is about, what they give read as written, the other readings, which one the machine runs by default, where the choice is made, and a program that shows the difference.

How to read an erratum

Each erratum names the sentences of the text it is about, quoted from the pinned spec.html (a step or a rule is found by the hash the overlay records of its text, so a change to the text fails the build), and the readings the overlay holds: the literal text, the sentence as written; the test262 reading, the one test262's tests require; the proposed reading, the text proposed in its place. Where two readings have the same text, it is given once. The notes are the overlay's own.

Of the 38 errata, 21 are read by default as test262 requires, 12 as written and 5 as proposed. 29 are switched in the specification at run time, 5 only in the engine's parser, and 4 have one reading.

29 errata have a program that shows them. Each program was run when this site was built, 59 runs in all on the native ecma-run, under its erratum's default reading and under its other reading (the literal text, or, where the default is the literal text, the proposed or test262 reading), and printed what the page says. An object's number in a result line is written #N.

Defects of the text (36)

Places where the text, read as written, gives no answer, an answer that contradicts another sentence, or an answer test262 does not accept.

ErratumClauseDefaultSwitchedProgram
UnitChainChild14.13.2 Static Semantics: IsLabelledFunctiontest262specyes
StringValueReservedWord13.1.1 Static Semantics: Early Errorstest262specyes
LookaheadSourceTokens5.1.6.7 Lookahead Restrictionstest262parseryes
HTMLCloseCommentTokenB.1.1 HTML-like Commentstest262parseryes
AnnexBRegExpOrderB.1.2 Regular Expressions Patternstest262parseryes
AnnexBGroupCountB.1.2 Regular Expressions Patternstest262parseryes
AnnexBModifierEarlyErrors22.2.1.1 Static Semantics: Early Errorstest262specyes
CoveredNodeParent5.1.5 The Syntactic Grammartest262parseryes
NumberMultiplyZeroSign6.1.6.1.4 Number::multiplyproposedspecyes
GatherAvailableAncestorsEmptyCycleRoot16.2.1.6.1.3.3 GatherAvailableAncestorsliteralspecyes
BuiltinReturnCompletion10.3.3 BuiltinCallOrConstructtest262specyes
ExecuteModuleAsyncDisposeResources16.2.1.7.3.2 ExecuteModuletest262specyes
ParseTextErrorObjects11.1.6 Static Semantics: ParseTextliteralspec
DoWaitSyncTimeout25.4.3.14 DoWaittest262specyes
AtomicsWaitAsyncTimeoutAssert25.4.3.15 EnqueueAtomicsWaitAsyncTimeoutJobliteralspec
AtomicsWaitAsyncTimeoutNegativeDelay25.4.3.15 EnqueueAtomicsWaitAsyncTimeoutJobliteralspec
GetUTCEpochNanosecondsNaN21.4.1.26 UTCliteralspecyes
GetMatchStringStartAfterEnd22.2.7.2 RegExpBuiltinExecliteralspecyes
AsyncBlockStartAwaitResult27.10.5.2 AsyncBlockStarttest262specyes
PromiseJobAbruptCompletion27.5.2.1 NewPromiseReactionJobliteralspecyes
NativeFunctionInitialName20.2.3.5 Function.prototype.toStringliteralspec
SyntheticModuleLinkResets16.2.1.8.4.4 Linkliteralspecyes
CreateDynamicFunctionPrivateIdentifiers20.2.1.1.1 CreateDynamicFunctionproposedspecyes
LonePropertyGeneralCategoryAssert22.2.2.9 Runtime Semantics: CompileToCharSettest262specyes
AllocateSharedArrayBufferByteLengthStore25.2.2.1 AllocateSharedArrayBuffertest262specyes
ContainsAwaitCover8.5.1 Static Semantics: Containstest262specyes
SplitCodeUnitStrings22.1.3.23 String.prototype.splittest262specyes
RacesNotBoth29.8 Racesliteralnone
InitHappensBeforeOverlap29.6.6 happens-beforeliteralnone
MemoryRangeSameBlock29.6.2 reads-bytes-fromproposednone
CreateIntrinsicsAsyncArgument9.3.2 CreateIntrinsicstest262specyes
SortInfiniteComparator23.1.3.30.1 SortIndexedPropertiestest262specyes
UnregisterIteratesCopy26.2.3.3 FinalizationRegistry.prototype.unregistertest262specyes
IsCharacterClassControlLetterB.1.2.3 Static Semantics: IsCharacterClasstest262specyes
StringMaximumLength22.1.3.18 String.prototype.repeatproposedspec
MVDecimalIntegerLiteralZero12.9.3.2 Static Semantics: MVliteralnone

UnitChainChild

default: test262switched: spec

Write-up 36. IsLabelledFunction tests a Statement node for being a LabelledStatement: always false

§14.13.2 Static Semantics: IsLabelledFunction, steps 1 and 2

If stmt is not a LabelledStatement, return false. … Let item be the LabelledItem of stmt.

The overlay's note

"the X of n" names a child of n (§5.1.2 gives a node only its right-hand side's children), so IsLabelledFunction 1-2 never find the LabelledStatement under a Statement node: read by §5.1.2 alone, step 1 returns false for every Statement node and if (1) l: function f() {} is valid; test262's labelled-fn-stmt*.js require a SyntaxError. The model reads "n is a X" through the unit chain, so its literal reading passes step 1 and stops (a sort error) at step 2, where n's production has no X. The test262 and proposed reading: X is taken from the first node of n's unit chain whose production has one.

Default
The test262 reading.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum UnitChainChild=READING runs a program under one of them (literal, test262, proposed), and the engine's theorem holds under every choice.

The program tests/run/erratum_unit_chain_child.js, run as ecma-run --web-browser tests/run/erratum_unit_chain_child.js with the option of each row:

The test262 reading (the default)
--erratum UnitChainChild=test262
throw: SyntaxError
The literal text
--erratum UnitChainChild=literal
stop: sortError sec-islabelledfunction#0 2: stops at §14.13.2 Static Semantics: IsLabelledFunction, step 2 (a value of the wrong sort reaches the step)

Open in the debugger: The specification Open in the debugger: The specification, with the literal text Open in the debugger: The literal text

Source
// IsLabelledFunction takes "the |LabelledItem| of" a |Statement| node through
// its unit chain (Erratum UnitChainChild, test262's reading): the labelled
// function in an if body is the Early Error of sec-if-statement-static-semantics-early-errors.
// args: --web-browser
// expect: throw: SyntaxError
if (1) l: function f() {}

StringValueReservedWord

default: test262switched: spec

Write-up 32. Identifier early errors take the StringValue of a ReservedWord, which StringValue does not define

§13.1.1 Static Semantics: Early Errors, the early-error rule of Identifier : IdentifierName but not ReservedWord

It is a Syntax Error if the StringValue of IdentifierName is the StringValue of any ReservedWord except for yield or await.

The test262 and proposed readings

It is a Syntax Error if the StringValue of IdentifierName is the String value of any terminal of ReservedWord except for yield or await.

The overlay's note

"the StringValue of any ReservedWord except for yield or await" takes the StringValue of a ReservedWord, for which StringValue has no row. The literal text stops there. The test262 and proposed reading: the StringValue of a terminal is the String value of its code points (test262's val--via-escape-.js require a SyntaxError for an IdentifierName that spells a reserved word with escapes).

Default
The test262 reading.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum StringValueReservedWord=READING runs a program under one of them (literal, test262, proposed), and the engine's theorem holds under every choice.

The program tests/run/erratum_stringvalue_reserved_word.js, run as ecma-run tests/run/erratum_stringvalue_reserved_word.js with the option of each row:

The test262 reading (the default)
--erratum StringValueReservedWord=test262
throw: SyntaxError
The literal text
--erratum StringValueReservedWord=literal
stop: sortError ph-stringvalue-any-nt-except#0 1: stops at ph-stringvalue-any-nt-except (a reading of the overlay), step 1 (a value of the wrong sort reaches the step)

Open in the debugger: The specification Open in the debugger: The specification, with the literal text

Source
// An |IdentifierName| spelling `if` with an escape is the String value of a
// terminal of |ReservedWord| (Erratum StringValueReservedWord, test262's reading).
// expect: throw: SyntaxError
var \u0069f;

LookaheadSourceTokens

default: test262switched: parser

Write-up 44. Lookahead restrictions over an automatically inserted semicolon

§5.1.6.7 Lookahead Restrictions

If the phrase “[lookahead = seq]” appears in the right-hand side of a production, it indicates that the production may only be used if the token sequence seq is a prefix of the immediately following input token sequence.

§12.10 Automatic Semicolon Insertion

These situations are described by saying that semicolons are automatically inserted into the source code token stream in those situations.

The overlay's note

A lookahead restriction reads "the immediately following input token sequence" (§5.1.6.7), and §12.10 inserts semicolons "into the source code token stream": the text does not say whether an inserted semicolon is a token a lookahead reads. Read as one, if (0) let LF [a] = 0; is a sentence. The literal text stops wherever a lookahead reads at an inserted semicolon. The test262 and proposed reading: a lookahead reads the source's tokens, past the semicolons §12.10 inserted (test262's let-array-with-newline.js require a SyntaxError).

Default
The test262 reading.
Switched
Only in the engine's parser. The specification's grammar (lean/Ecma/Grammar/Gen) has the default reading; the engine's parser has both, and ecma-run --erratum LookaheadSourceTokens=literal parses as the text is written. The literal reading is the engine's parser's, not the specification layer's.

The program tests/run/erratum_lookahead_source_tokens.js, run as ecma-run tests/run/erratum_lookahead_source_tokens.js with the option of each row:

The test262 reading (the default)
--erratum LookaheadSourceTokens=test262
throw: SyntaxError
The literal text
--erratum LookaheadSourceTokens=literal
stop: residue formal-parsetextin#0 2: stops at formal-parsetextin (a reading of the overlay), step 2 (a step of the text with no reading the machine can run)

Open in the debugger: The specification Open in the debugger: The specification, with the literal text

Source
// The inserted `;` after `let` is no source token: ExpressionStatement's lookahead
// reads `let [` and the program has no parse (Erratum LookaheadSourceTokens,
// test262's reading).
// expect: throw: SyntaxError
if (0) let
[a] = 0;

HTMLCloseCommentToken

default: test262switched: parser

Write-up 41. Annex B: a first-line --> is an input element that is neither a comment nor a token

§B.1.1 HTML-like Comments, the definition of InputElementHashbangOrRegExp

InputElementHashbangOrRegExp :: WhiteSpace LineTerminator Comment CommonToken HashbangComment RegularExpressionLiteral HTMLCloseComment

§5.1.3 The Lexical and RegExp Grammars

Input elements other than white space and comments form the terminal symbols for the syntactic grammar for ECMAScript and are called ECMAScript tokens.

The overlay's note

B.1.1 adds HTMLCloseComment as an alternative of InputElementHashbangOrRegExp of its own, not under Comment, and §5.1.3 drops only white space and comments from the input elements: literally a first-line --> is a token that no syntactic production has, and the Script has no parse (a SyntaxError). The test262 and proposed reading: an HTMLCloseComment input element is a comment (test262's single-line-html-close-first-line-{1,2,3}.js).

Read as written
The text never stops a run.
Default
The test262 reading.
Switched
Only in the engine's parser. The specification's grammar (lean/Ecma/Grammar/Gen) has the default reading; the engine's parser has both, and ecma-run --erratum HTMLCloseCommentToken=literal parses as the text is written. The literal reading is the engine's parser's, not the specification layer's.

The program tests/run/erratum_html_close_comment_token.js, run as ecma-run --annex-b sec-html-like-comments tests/run/erratum_html_close_comment_token.js with the option of each row:

The test262 reading (the default)
--erratum HTMLCloseCommentToken=test262
normal: 1
The literal text
--erratum HTMLCloseCommentToken=literal
stop: residue formal-parsetextin#0 2: stops at formal-parsetextin (a reading of the overlay), step 2 (a step of the text with no reading the machine can run)

Open in the debugger: The specification Open in the debugger: The specification, with the literal text

Source
--> the Script's first input element: an HTMLCloseComment
// A first-line `-->` is an HTMLCloseComment, a comment (Erratum
// HTMLCloseCommentToken, test262's reading).
// args: --annex-b sec-html-like-comments
// expect: normal: 1
1

AnnexBRegExpOrder

default: test262switched: parser

Write-up 40. Annex B: what §B.1.2's ordered alternatives choose, and which Pattern its group-number condition counts

§B.1.2 Regular Expressions Patterns

When parsing using the following grammar, each alternative is considered only if previous production alternatives do not match.

The overlay's note

B.1.2's "each alternative is considered only if previous production alternatives do not match" says neither what an alternative matches nor how nested choices combine, and without an order its grammar is ambiguous (/a{1}/, /\b*/, /\1/). The literal text stops on a pattern with more than one parse. The test262 and proposed reading: commitment: a node of a nonterminal B.1.2 restates uses an alternative only if no earlier alternative of it derives any span from the node's start (tc39/ecma262 #2228; test262's annexB/built-ins/RegExp).

Default
The test262 reading.
Switched
Only in the engine's parser. The specification's grammar (lean/Ecma/Grammar/Gen) has the default reading; the engine's parser has both, and ecma-run --erratum AnnexBRegExpOrder=literal parses as the text is written. The literal reading is the engine's parser's, not the specification layer's.

The program tests/run/erratum_annexb_regexp_order.js, run as ecma-run --annex-b sec-regular-expressions-patterns tests/run/erratum_annexb_regexp_order.js with the option of each row:

The test262 reading (the default)
--erratum AnnexBRegExpOrder=test262
throw: SyntaxError
The literal text
--erratum AnnexBRegExpOrder=literal
stop: residue formal-parsetextin#0 2: stops at formal-parsetextin (a reading of the overlay), step 2 (a step of the text with no reading the machine can run)

Open in the debugger: The specification Open in the debugger: The specification, with the literal text

Source
// B.1.2's alternatives commit in order: `\b*` is an Assertion, which no
// quantifier follows, and the literal has no parse (Erratum AnnexBRegExpOrder,
// test262's reading).
// args: --annex-b sec-regular-expressions-patterns
// expect: throw: SyntaxError
/\b*/;

AnnexBGroupCount

default: test262switched: parser

Write-up 40. Annex B: what §B.1.2's ordered alternatives choose, and which Pattern its group-number condition counts

§B.1.2 Regular Expressions Patterns, the condition on AtomEscape :: DecimalEscape

[~UnicodeMode] DecimalEscape [> but only if the CapturingGroupNumber of DecimalEscape is ≤ CountLeftCapturingParensWithin(the Pattern containing DecimalEscape)]

The overlay's note

B.1.2's condition on AtomEscape :: DecimalEscape, "the CapturingGroupNumber of DecimalEscape is ≤ CountLeftCapturingParensWithin(the Pattern containing DecimalEscape)", reads the Pattern whose parse the condition itself decides. The literal text stops on a pattern with more than one parse. The test262 and proposed reading: stratified: the count is that of a committed parse of the input as Pattern[~UnicodeMode, ~UnicodeSetsMode, ~NamedCaptureGroups] with the condition true (test262's legacy-octal-escape.js).

Default
The test262 reading.
Switched
Only in the engine's parser. The specification's grammar (lean/Ecma/Grammar/Gen) has the default reading; the engine's parser has both, and ecma-run --erratum AnnexBGroupCount=literal parses as the text is written. The literal reading is the engine's parser's, not the specification layer's.

The program tests/run/erratum_annexb_group_count.js, run as ecma-run --annex-b sec-regular-expressions-patterns tests/run/erratum_annexb_group_count.js with the option of each row:

The test262 reading (the default)
--erratum AnnexBGroupCount=test262
normal: true
The literal text
--erratum AnnexBGroupCount=literal
stop: residue formal-parsetextin#0 2: stops at formal-parsetextin (a reading of the overlay), step 2 (a step of the text with no reading the machine can run)

Open in the debugger: The specification Open in the debugger: The specification, with the literal text

Source
// `\1` with one capturing group is a backreference: the group count is read
// from a committed parse (Erratum AnnexBGroupCount, test262's reading).
// args: --annex-b sec-regular-expressions-patterns
// expect: normal: true
/(a)\1/.test("aa");

AnnexBModifierEarlyErrors

default: test262switched: spec

Write-up 26. Annex B: /(?ii:a)/ has no early error under §B.1.2

§22.2.1.1 Static Semantics: Early Errors, the early-error rule of Atom :: `(?` RegularExpressionModifiers `:` Disjunction `)`

It is a Syntax Error if the source text matched by RegularExpressionModifiers contains the same code point more than once.

The test262 and proposed readings

It is a Syntax Error if the source text matched by RegularExpressionModifiers contains the same code point more than once.

§22.2.1.1 Static Semantics: Early Errors, the early-error rule of Atom :: `(?` RegularExpressionModifiers `-` RegularExpressionModifiers `:` Disjunction `)`

It is a Syntax Error if the source text matched by the first RegularExpressionModifiers and the source text matched by the second RegularExpressionModifiers are both empty.

The test262 and proposed readings

It is a Syntax Error if the source text matched by the first RegularExpressionModifiers and the source text matched by the second RegularExpressionModifiers are both empty.

§22.2.1.1 Static Semantics: Early Errors, the early-error rule of Atom :: `(?` RegularExpressionModifiers `-` RegularExpressionModifiers `:` Disjunction `)`

It is a Syntax Error if the source text matched by the first RegularExpressionModifiers contains the same code point more than once.

The test262 and proposed readings

It is a Syntax Error if the source text matched by the first RegularExpressionModifiers contains the same code point more than once.

§22.2.1.1 Static Semantics: Early Errors, the early-error rule of Atom :: `(?` RegularExpressionModifiers `-` RegularExpressionModifiers `:` Disjunction `)`

It is a Syntax Error if the source text matched by the second RegularExpressionModifiers contains the same code point more than once.

The test262 and proposed readings

It is a Syntax Error if the source text matched by the second RegularExpressionModifiers contains the same code point more than once.

§22.2.1.1 Static Semantics: Early Errors, the early-error rule of Atom :: `(?` RegularExpressionModifiers `-` RegularExpressionModifiers `:` Disjunction `)`

It is a Syntax Error if any code point in the source text matched by the first RegularExpressionModifiers is also contained in the source text matched by the second RegularExpressionModifiers.

The test262 and proposed readings

It is a Syntax Error if any code point in the source text matched by the first RegularExpressionModifiers is also contained in the source text matched by the second RegularExpressionModifiers.

The overlay's note

§22.2.1.1's modifier rules are on Atom's productions; under B.1.2's grammar (?ii:a) is an ExtendedAtom, for which B.1.2.1 adds no such rule, so literally /(?ii:a)/, /(?-:a)/ and /(?i-i:a)/ are valid patterns without the u or v flag on a B.1.2 host. The test262 and proposed reading: §22.2.1.1's rules of the two modifier productions of Atom apply to the ExtendedAtom productions with the same right-hand sides.

Read as written
The text never stops a run.
Default
The test262 reading.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum AnnexBModifierEarlyErrors=READING runs a program under one of them (literal, test262, proposed), and the engine's theorem holds under every choice.

The program tests/run/erratum_annexb_modifier_early_errors.js, run as ecma-run --annex-b sec-regular-expressions-patterns tests/run/erratum_annexb_modifier_early_errors.js with the option of each row:

The test262 reading (the default)
--erratum AnnexBModifierEarlyErrors=test262
throw: SyntaxError
The literal text
--erratum AnnexBModifierEarlyErrors=literal
normal: [object #N]

Open in the debugger: The specification Open in the debugger: The specification, with the literal text

Source
// §22.2.1.1's modifier rules hold on B.1.2's ExtendedAtom: `(?ii:a)` repeats a
// modifier (Erratum AnnexBModifierEarlyErrors, test262's reading).
// args: --annex-b sec-regular-expressions-patterns
// expect: throw: SyntaxError
/(?ii:a)/;

CoveredNodeParent

default: test262switched: parser

Write-up 46. A covered Parse Node is outside the tree that covers it

§5.1.5 The Syntactic Grammar

The sequence of tokens originally matched by p is parsed again using n as the goal symbol.

§15.10.1 Static Semantics: IsInTailPosition, step 2

Let body be the FunctionBody, ConciseBody, or AsyncConciseBody that most closely contains call.

The overlay's note

§5.1.5 reparses a cover with n as goal, so the covered node roots a tree of its own: "contained within", "most closely contains" and "the parent of" (IsInTailPosition 2, MightBothParticipate 1, ShallowestContainedJSONValue 6.d) fail for a node inside it, and read literally return (f(n - 1)) is no tail call. The test262 and proposed reading: the covered node takes the cover's place in the tree, its parent being the cover's parent (test262's tco-pos.js).

Read as written
The text never stops a run.
Default
The test262 reading.
Switched
Only in the engine's parser. The specification's grammar (lean/Ecma/Grammar/Gen) has the default reading; the engine's parser has both, and ecma-run --erratum CoveredNodeParent=literal parses as the text is written. The literal reading is the engine's parser's, not the specification layer's.

The program tests/run/erratum_covered_node_parent.js, run as ecma-run tests/run/erratum_covered_node_parent.js with the option of each row:

The test262 reading (the default)
--erratum CoveredNodeParent=test262
normal: 0
The literal text
--erratum CoveredNodeParent=literal
stop: residue sec-grouping-operator-static-semantics-early-errors#0 ?: stops at §13.2.9.1 Static Semantics: Early Errors (a step of the text with no reading the machine can run)

Open in the debugger: The specification Open in the debugger: The specification, with the literal text

Source
// Erratum CoveredNodeParent at its test262 reading: the covered
// |ParenthesizedExpression| takes its cover's place, so `return (f(n - 1))` is
// in tail position (test262 tco-pos.js).
// expect: normal: 0
"use strict";
function f(n) {
  if (n === 0) return 0;
  return (f(n - 1));
}
f(3);

NumberMultiplyZeroSign

default: proposedswitched: spec

Write-up 01. Number::multiply gives +0 for +0 × -5

§6.1.6.1.4 Number::multiply, step 6

Return 𝔽(ℝ(x) × ℝ(y)).

The proposed reading
  1. If x is +0𝔽 and y < -0𝔽, return -0𝔽.
  2. If y is +0𝔽 and x < -0𝔽, return -0𝔽.
  3. Return 𝔽(ℝ(x) × ℝ(y)).
Default
The proposed reading. The overlay's resolution is pending: not yet decided; the machine runs the proposed reading until it is.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum NumberMultiplyZeroSign=READING runs a program under one of them (literal, proposed), and the engine's theorem holds under every choice.

The program tests/run/number_multiply_zero_sign.js, run as ecma-run tests/run/number_multiply_zero_sign.js with the option of each row:

The proposed reading (the default)
--erratum NumberMultiplyZeroSign=proposed
normal: undefined
  • -Infinity,-Infinity,Infinity,-Infinity,Infinity,Infinity,-Infinity
The literal text
--erratum NumberMultiplyZeroSign=literal
normal: undefined
  • Infinity,Infinity,Infinity,-Infinity,Infinity,Infinity,-Infinity

Open in the debugger: The specification Open in the debugger: The specification, with the literal text Open in the debugger: The literal text

Source
// expect: normal: undefined
// print: -Infinity,-Infinity,Infinity,-Infinity,Infinity,Infinity,-Infinity
// Number::multiply step 6 gives 𝔽(0) = +0 for +0 × -5; the clause's
// description (IEEE 754-2019) and every engine give -0 (Erratum
// NumberMultiplyZeroSign, read by default as proposed: no test262 assertion
// covers the case). A product that underflows keeps
// its sign by 𝔽 itself.
print(String([1 / (0 * -5), 1 / (-5 * 0), 1 / (0 * 5), 1 / (-0 * 5), 1 / (-0 * -5), 1 / (0 * 0),
  1 / (1e-300 * -1e-300)]));

GatherAvailableAncestorsEmptyCycleRoot

default: literalswitched: spec

Write-up 02. GatherAvailableAncestors reads the [[CycleRoot]] of a module whose evaluation threw

§16.2.1.6.1.3.3 GatherAvailableAncestors, step 1.a

If execList does not contain ancestorModule and ancestorModule.[[CycleRoot]].[[EvaluationError]] is empty, then

The proposed reading
  1. If execList does not contain ancestorModule and ancestorModule.[[EvaluationError]] is empty, then
    1. Assert: ancestorModule.[[Status]] is evaluating-async.
    2. Assert: ancestorModule.[[CycleRoot]] is not empty.
    3. If ancestorModule.[[CycleRoot]].[[EvaluationError]] is empty, then
      1. Assert: ancestorModule.[[AsyncEvaluationOrder]] is an integer.
      2. Assert: ancestorModule.[[PendingAsyncDependencies]] > 0.
      3. Set ancestorModule.[[PendingAsyncDependencies]] to ancestorModule.[[PendingAsyncDependencies]] - 1.
      4. If ancestorModule.[[PendingAsyncDependencies]] = 0, then
        1. Append ancestorModule to execList.
        2. If ancestorModule.[[HasTLA]] is false, perform GatherAvailableAncestors(ancestorModule, execList).
Read as written
A run stops at §16.2.1.6.1.3.3 GatherAvailableAncestors, step 1.a.
Default
The literal text.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum GatherAvailableAncestorsEmptyCycleRoot=READING runs a program under one of them (literal, proposed), and the engine's theorem holds under every choice.

The program tests/run/module_erratum_cycle_root.js, run as ecma-run --module --module-dir tests/run/modules tests/run/module_erratum_cycle_root.js with the option of each row:

The literal text (the default)
--erratum GatherAvailableAncestorsEmptyCycleRoot=literal
stop: erratum GatherAvailableAncestorsEmptyCycleRoot sec-gather-available-ancestors#0 1.a: stops at §16.2.1.6.1.3.3 GatherAvailableAncestors, step 1.a (the step this erratum names)
The proposed reading
--erratum GatherAvailableAncestorsEmptyCycleRoot=proposed
throw: Error: c
  • b
Source
// module: yes
// args: --module-dir tests/run/modules
// expect: stop: erratum GatherAvailableAncestorsEmptyCycleRoot sec-gather-available-ancestors#0 1.a
// A module whose synchronous evaluation threw has no [[CycleRoot]] (Evaluate
// step 9.a). When its async dependency b finishes, GatherAvailableAncestors
// step 1.a reads a.[[CycleRoot]].[[EvaluationError]], a field of ~empty~: the
// pinned text has no result there (docs/spec-issues/02). No test262 test
// builds this graph, so the defect is kept literal (Erratum
// GatherAvailableAncestorsEmptyCycleRoot) and the run stops, naming it
// (`stop: erratum <Name> <site>`, exit 3: Engine/Cli/Run.lean). The proposed
// reading skips an ancestor whose [[EvaluationError]] is set: b runs to its
// end and c's error is the outcome (`--erratum
// GatherAvailableAncestorsEmptyCycleRoot=proposed`: `throw: Error: c`, then b).
import "./f22_a.mjs";

BuiltinReturnCompletion

default: test262switched: spec

Write-up 03. A built-in async function's promise fulfils with undefined

§10.3.3 BuiltinCallOrConstruct, step 10.b.iii

Return Completion(result).

The test262 and proposed readings
  1. If result is a normal completion, return ReturnCompletion(result.[[Value]]).
  2. Return ? result.
Default
The test262 reading.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum BuiltinReturnCompletion=READING runs a program under one of them (literal, test262, proposed), and the engine's theorem holds under every choice.

The program tests/run/builtin_async_return.js, run as ecma-run tests/run/builtin_async_return.js with the option of each row:

The test262 reading (the default)
--erratum BuiltinReturnCompletion=test262
normal: undefined
  • undefined
  • 1,2
The literal text
--erratum BuiltinReturnCompletion=literal
normal: undefined
  • undefined

Open in the debugger: The specification Open in the debugger: The specification, with the literal text

Source
// expect: normal: undefined
// print: undefined
// print: 1,2
// BuiltinCallOrConstruct step 10.b.iii under Erratum BuiltinReturnCompletion
// (its test262 reading): "Return array" of Array.fromAsync is a normal
// completion, which the resultsClosure gives to AsyncBlockStart as a return
// completion, so the promise is fulfilled with the array; disposeAsync's
// "Return ? DisposeResources(…)" fulfils it with undefined.
Array.fromAsync([1, 2]).then(function (a) { print(a.join(",")); });
new AsyncDisposableStack().disposeAsync().then(function (v) { print(String(v)); });
void 0;

ExecuteModuleAsyncDisposeResources

default: test262switched: spec

Write-up 04. A module with top-level await never disposes its top-level resources

§16.2.1.7.3.2 ExecuteModule, step 4.b

Perform AsyncBlockStart(capability, module.[[ECMAScriptCode]], moduleContext).

The test262 and proposed readings
  1. Let env be module.[[Environment]].
  2. Let asyncBody be a new Abstract Closure with no parameters that captures module and env and performs the following steps when called:
    1. Let result be Completion(Evaluation of module.[[ECMAScriptCode]]).
    2. Set result to Completion(DisposeResources(env.[[DisposableResourceStack]], result)).
    3. Return Completion(result).
  3. Perform AsyncBlockStart(capability, asyncBody, moduleContext).
Default
The test262 reading.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum ExecuteModuleAsyncDisposeResources=READING runs a program under one of them (literal, test262, proposed), and the engine's theorem holds under every choice.

The program tests/run/errata_execute_module_dispose.js, run as ecma-run --module tests/run/errata_execute_module_dispose.js with the option of each row:

The test262 reading (the default)
--erratum ExecuteModuleAsyncDisposeResources=test262
normal: undefined
  • end
  • disposed
The literal text
--erratum ExecuteModuleAsyncDisposeResources=literal
normal: undefined
  • end

Open in the debugger: The specification Open in the debugger: The specification, with the literal text

Source
// module: yes
// expect: normal: undefined
// print: end
// print: disposed
// A module with top-level await and `await using` (Erratum ExecuteModuleAsyncDisposeResources):
// the test262 reading disposes the module's resources after its body.
await using x = { [Symbol.asyncDispose]() { print("disposed"); } };
await 0;
print("end");

ParseTextErrorObjects

default: literalswitched: spec

Write-up 05. ParseText creates SyntaxError objects without a realm

§11.1.6 Static Semantics: ParseText, step 5

Return a List of one or more SyntaxError objects representing the parsing errors and/or early errors. If more than one parsing error or early error is present, the number and ordering of error objects in the list is implementation-defined, but at least one must be present.

The proposed reading
  1. Return « a newly created SyntaxError object ».
§22.2.3.4 Static Semantics: ParsePattern, step 1.a

Let parseResult be a List containing one or more SyntaxError objects.

The proposed reading
  1. Let parseResult be « a newly created SyntaxError object ».
§B.1.2.9 Static Semantics: ParsePattern, step 1.a

Let parseResult be a List containing one or more SyntaxError objects.

The proposed reading
  1. Let parseResult be « a newly created SyntaxError object ».

The overlay's note

The pinned text says ParseText and ParsePattern return "a List of one or more SyntaxError objects" (with an implementation-defined number and order when multiple errors exist), without specifying the Realm Record or concrete error objects. Every caller only checks whether the List is non-empty and throws a fresh SyntaxError of its own (or, for ParseScript/ParseModule hosts, takes an element), so the proposed reading returns a single newly created SyntaxError object in the current realm (write-up 05).

Read as written
The text never stops a run.
Default
The literal text.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum ParseTextErrorObjects=READING runs a program under one of them (literal, proposed), and the engine's theorem holds under every choice.

No program on this site shows this erratum.

DoWaitSyncTimeout

default: test262switched: spec

Write-up 06. A synchronous Atomics.wait that times out returns "ok"

§25.4.3.14 DoWait, step 28.a

Perform SuspendThisAgent(waiterList, waiterRecord).

The test262 reading
  1. Perform SuspendThisAgent(waiterList, waiterRecord).
  2. If waiterList.[[Waiters]] contains waiterRecord, then
    1. Set waiterRecord.[[Result]] to "timed-out".
    2. Perform RemoveWaiter(waiterList, waiterRecord).
The proposed reading
  1. Perform SuspendThisAgent(waiterList, waiterRecord).
  2. If waiterList.[[Waiters]] contains waiterRecord, then
    1. NOTE: The agent woke because of the timeout: NotifyWaiter is performed only on a Waiter Record that RemoveWaiters has removed.
    2. Set waiterRecord.[[Result]] to "timed-out".
    3. Perform RemoveWaiter(waiterList, waiterRecord).
Read as written
A run stops at §25.4.3.8 AddWaiter, step 2.
Default
The test262 reading.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum DoWaitSyncTimeout=READING runs a program under one of them (literal, test262, proposed), and the engine's theorem holds under every choice.

The program tests/run/atomics_wait_sync_timeout.js, run as ecma-run --can-block tests/run/atomics_wait_sync_timeout.js with the option of each row:

The test262 reading (the default)
--erratum DoWaitSyncTimeout=test262
normal: undefined
  • timed-out,timed-out,true,true,0 ; not-equal
The literal text
--erratum DoWaitSyncTimeout=literal
stop: erratum DoWaitSyncTimeout sec-addwaiter#0 2: stops at §25.4.3.8 AddWaiter, step 2 (the step this erratum names)

Open in the debugger: The specification Open in the debugger: The specification, with the literal text Open in the debugger: The literal text

Source
// Atomics.wait on an agent that can block (§25.4.3.14, SuspendThisAgent
// §25.4.3.11): with one agent nothing notifies the waiter, so it wakes when
// the host's clock reaches its timeout time. Erratum DoWaitSyncTimeout: the
// woken waiter's [[Result]] is "timed-out" and it leaves the WaiterList, so a
// second wait on the same location does not fail AddWaiter step 2's Assert
// and a later Atomics.notify finds no waiter.
// args: --can-block
// expect: normal: undefined
// print: timed-out,timed-out,true,true,0 ; not-equal
var i32 = new Int32Array(new SharedArrayBuffer(8));
var t0 = Date.now();
var first = Atomics.wait(i32, 0, 0, 10);
var t1 = Date.now();
var second = Atomics.wait(i32, 0, 0, 5);
var t2 = Date.now();
var notified = Atomics.notify(i32, 0);
Atomics.store(i32, 1, 3);
print([first, second, t1 - t0 >= 10, t2 - t1 >= 5, notified].join() + " ; " + Atomics.wait(i32, 1, 0, 10));
void 0;

AtomicsWaitAsyncTimeoutAssert

default: literalswitched: spec

Write-up 09. EnqueueAtomicsWaitAsyncTimeoutJob passes a negative delay, and its Assert can fail

§25.4.3.15 EnqueueAtomicsWaitAsyncTimeoutJob, step 1.b.ii

Assert: ℝ(timeOfJobExecution) ≥ waiterRecord.[[TimeoutTime]] (ignoring potential non-monotonicity of time values).

The proposed reading
  1. Assert: timeOfJobExecution ≥ 𝔽(waiterRecord.[[TimeoutTime]]) rounded down to an integral Number (ignoring potential non-monotonicity of time values).
Read as written
A run stops at §25.4.3.15 EnqueueAtomicsWaitAsyncTimeoutJob, step 1.b.ii.
Default
The literal text.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum AtomicsWaitAsyncTimeoutAssert=READING runs a program under one of them (literal, proposed), and the engine's theorem holds under every choice.

No program on this site shows this erratum.

AtomicsWaitAsyncTimeoutNegativeDelay

default: literalswitched: spec

Write-up 09. EnqueueAtomicsWaitAsyncTimeoutJob passes a negative delay, and its Assert can fail

§25.4.3.15 EnqueueAtomicsWaitAsyncTimeoutJob, step 4

Perform HostEnqueueTimeoutJob(timeoutJob, currentRealm, 𝔽(waiterRecord.[[TimeoutTime]]) - now).

The proposed reading
  1. Let delay be 𝔽(waiterRecord.[[TimeoutTime]]) - now.
  2. If delay < +0𝔽, set delay to +0𝔽.
  3. Perform HostEnqueueTimeoutJob(timeoutJob, currentRealm, delay).

The overlay's note

now is read after DoWait's reading from which [[TimeoutTime]] was computed, so the literal difference is negative when the clock has advanced past [[TimeoutTime]], and HostEnqueueTimeoutJob takes a non-negative finite Number. The proposed reading clamps the text's own difference at zero, so that now + delay is 𝔽([[TimeoutTime]]) whenever the delay is positive: the Job runs no earlier than that time value, which is what AtomicsWaitAsyncTimeoutAssert's proposed Assert needs. Clamping the exact difference instead (𝔽(max([[TimeoutTime]] - ℝ(now), 0))) can round the delay down across a millisecond that 𝔽([[TimeoutTime]]) rounds up to.

Read as written
A run stops at §25.4.3.15 EnqueueAtomicsWaitAsyncTimeoutJob, step 4.
Default
The literal text.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum AtomicsWaitAsyncTimeoutNegativeDelay=READING runs a program under one of them (literal, proposed), and the engine's theorem holds under every choice.

No program on this site shows this erratum.

GetUTCEpochNanosecondsNaN

default: literalswitched: spec

Write-up 10. new Date(0).setHours(1e21): UTC ( t ) reaches a failing Assert

§21.4.1.26 UTC, step 1

If t is not a finite Number, return NaN.

The proposed reading
  1. If t is not a finite Number, return NaN.
  2. If MakeDay(𝔽(YearFromTime(t)), 𝔽(MonthFromTime(t)), 1𝔽) is NaN, return NaN.
Read as written
A run stops at §21.4.1.18 GetUTCEpochNanoseconds, step 4.
Default
The literal text.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum GetUTCEpochNanosecondsNaN=READING runs a program under one of them (literal, proposed), and the engine's theorem holds under every choice.

The program tests/run/date_utc_large_local_time.js, run as ecma-run tests/run/date_utc_large_local_time.js with the option of each row:

The literal text (the default)
--erratum GetUTCEpochNanosecondsNaN=literal
stop: erratum GetUTCEpochNanosecondsNaN sec-getutcepochnanoseconds#0 4: stops at §21.4.1.18 GetUTCEpochNanoseconds, step 4 (the step this erratum names)
The proposed reading
--erratum GetUTCEpochNanosecondsNaN=proposed
normal: undefined
  • NaN
  • NaN

Open in the debugger: The specification Open in the debugger: The specification, with the proposed reading Open in the debugger: The literal text

Source
// expect: stop: erratum GetUTCEpochNanosecondsNaN sec-getutcepochnanoseconds#0 4
// UTC ( t ) of a large finite local time: setHours(1e21) gives t = 3.6e24,
// GetUTCEpochNanoseconds step 1's MakeDay finds no time value on the month's
// first day (NaN), and the Assert of its step 4 fails. No test262 test
// reaches it, and the default reading is the text as written (Erratum
// GetUTCEpochNanosecondsNaN), so the run stops.
// Engines give NaN. The UTC setter does not call UTC ( t ): NaN.
print(String(new Date(0).setUTCHours(1e21)));
print(String(new Date(0).setHours(1e21)));

GetMatchStringStartAfterEnd

default: literalswitched: spec

Write-up 11. /u with lastIndex inside a surrogate pair: a match reported one code unit late, and a Match Record that ends before it starts

§22.2.7.2 RegExpBuiltinExec, step 13.b

Let inputIndex be the index into input of the character that was obtained from element lastIndex of string.

The proposed reading
  1. Let inputIndex be the index into input of the character that was obtained from element lastIndex of string.
  2. If fullUnicode is true, set lastIndex to GetStringIndex(string, inputIndex).
Read as written
A run stops at §22.2.7.6 GetMatchString, step 1, when called from §22.2.7.2 RegExpBuiltinExec.
Default
The literal text.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum GetMatchStringStartAfterEnd=READING runs a program under one of them (literal, proposed), and the engine's theorem holds under every choice.

The program tests/run/regexp_lastindex_inside_pair.js, run as ecma-run tests/run/regexp_lastindex_inside_pair.js with the option of each row:

The literal text (the default)
--erratum GetMatchStringStartAfterEnd=literal
stop: erratum GetMatchStringStartAfterEnd sec-getmatchstring#0 1: stops at §22.2.7.6 GetMatchString, step 1 (the step this erratum names)
The proposed reading
--erratum GetMatchStringStartAfterEnd=proposed
normal: [object #N]

Open in the debugger: The specification Open in the debugger: The specification, with the proposed reading Open in the debugger: The literal text

Source
// expect: stop: erratum GetMatchStringStartAfterEnd sec-getmatchstring#0 1
// RegExpBuiltinExec with /u and lastIndex on the trailing surrogate of a pair:
// step 13.b starts at the code point that contains it, the empty pattern
// matches there with [[EndIndex]] 0, and step 24's Match Record { 1, 0 } fails
// GetMatchString step 1's Assert. No test262 test sets lastIndex inside a
// pair before an empty match; the default reading is the text as written
// (Erratum GetMatchStringStartAfterEnd), so the run stops.
// V8 and SpiderMonkey report index 0; JavaScriptCore reports index 1.
// (The non-empty case, which does not stop, is
// regexp_lastindex_inside_pair_nonempty.js.)
var r = /(?:)/gu;
r.lastIndex = 1;
r.exec("\u{1F600}");

AsyncBlockStartAwaitResult

default: test262switched: spec

Write-up 12. AsyncBlockStart asserts unused, but Await resumes it with empty

§27.10.5.2 AsyncBlockStart, step 4

Assert: result is unused.

The test262 and proposed readings
  1. Assert: result is either unused or empty.
Read as written
A run stops at §27.10.5.2 AsyncBlockStart, step 4.
Default
The test262 reading.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum AsyncBlockStartAwaitResult=READING runs a program under one of them (literal, test262, proposed), and the engine's theorem holds under every choice.

The program tests/dbg/async.js, run as ecma-run tests/dbg/async.js with the option of each row:

The test262 reading (the default)
--erratum AsyncBlockStartAwaitResult=test262
normal: [object #N]
  • 2
The literal text
--erratum AsyncBlockStartAwaitResult=literal
stop: erratum AsyncBlockStartAwaitResult sec-asyncblockstart#0 4: stops at §27.10.5.2 AsyncBlockStart, step 4 (the step this erratum names)

Open in the debugger: The specification Open in the debugger: The specification, with the literal text Open in the debugger: The literal text

Source
async function h() {
  var a = 1;
  await a;
  a = a + 1;
  return a;
}
var p = h();
p.then(function (v) { print(v); });
var z = 3;

PromiseJobAbruptCompletion

default: literalswitched: spec

Write-up 13. NewPromiseReactionJob returns the throw completion of a resolving function

§27.5.2.1 NewPromiseReactionJob, step 1.h

If handlerResult is an abrupt completion, then

The proposed reading
  1. If handlerResult is an abrupt completion, then
    1. Let settleResult be Completion(Call(promiseCapability.[[Reject]], undefined, « handlerResult.[[Value]] »)).
  2. Else,
    1. Let settleResult be Completion(Call(promiseCapability.[[Resolve]], undefined, « handlerResult.[[Value]] »)).
§27.5.2.1 NewPromiseReactionJob, step 1.i

Return ? Call(promiseCapability.[[Resolve]], undefined, « handlerResult.[[Value]] »).

The proposed reading
  1. If settleResult is an abrupt completion, perform HostReportErrors(« settleResult.[[Value]] »).
  2. Return empty.
Read as written
A run stops at §9.5 Jobs and Host Operations to Enqueue Jobs, the job loop's check of a Job's abrupt completion (§9.5), when called from §27.5.2.1 NewPromiseReactionJob.
Default
The literal text.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum PromiseJobAbruptCompletion=READING runs a program under one of them (literal, proposed), and the engine's theorem holds under every choice.

The program tests/run/promise_job_abrupt.js, run as ecma-run tests/run/promise_job_abrupt.js with the option of each row:

The literal text (the default)
--erratum PromiseJobAbruptCompletion=literal
stop: erratum PromiseJobAbruptCompletion sec-jobs -: stops at §9.5 Jobs and Host Operations to Enqueue Jobs, the job loop's check of a Job's completion (the step this erratum names)
The proposed reading
--erratum PromiseJobAbruptCompletion=proposed
normal: [object #N]
  • handler 1
  • a later Job

Open in the debugger: The specification Open in the debugger: The specification, with the proposed reading Open in the debugger: The literal text

Source
// expect: stop: erratum PromiseJobAbruptCompletion sec-jobs -
// NewPromiseReactionJob 1.i returns `? Call(promiseCapability.[[Resolve]], …)`;
// with a species constructor whose resolve throws, the Job returns a throw
// completion, which §9.5 says a Job must not. No test262 test makes a
// reaction Job's resolving function throw; the default reading is the text
// as written (Erratum PromiseJobAbruptCompletion), so the run
// stops. (Engine hosts differ: node goes on silently; the SpiderMonkey shell
// and Bun, with JavaScriptCore, report the throw and go on.)
function Bad(executor) {
  executor(function () { throw new Error("boom"); }, function () {});
}
Bad[Symbol.species] = Bad;
var p = Promise.resolve(1);
p.constructor = Bad;
p.then(function (v) { print("handler " + v); return v; });
Promise.resolve(3).then(function () { print("a later Job"); });

NativeFunctionInitialName

default: literalswitched: spec

Write-up 14. Function.prototype.toString has no conforming result for some [[InitialName]] values

§20.2.3.5 Function.prototype.toString, step 3

If func is a built-in function object, return an implementation-defined String source code representation of func. The representation must have the syntax of a NativeFunction. Additionally, if func has an [[InitialName]] internal slot and func.[[InitialName]] is a String, the portion of the returned String that would be matched by NativeFunctionAccessor? PropertyName must be func.[[InitialName]].

The proposed reading
  1. If func is a built-in function object, return NativeFunctionSource(func).

The overlay's note

The proposed text: "If func is a built-in function object, return an implementation-defined String source code representation of func. The representation must have the syntax of a NativeFunction. Additionally, if func has an [[InitialName]] internal slot, func.[[InitialName]] is a String, and func.[[InitialName]] is matched by NativeFunctionAccessor? PropertyName, the portion of the returned String that would be matched by NativeFunctionAccessor? PropertyName must be func.[[InitialName]]." Both requirements are NativeFunctionSource's law.

Read as written
The text never stops a run.
Default
The literal text.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum NativeFunctionInitialName=READING runs a program under one of them (literal, proposed), and the engine's theorem holds under every choice.

No program on this site shows this erratum.

SyntheticModuleLinkResets

default: literalswitched: spec

Write-up 15. A second Link of a Synthetic Module Record resets its exports, observably with JSON modules

§16.2.1.8.4.4 Link, step 1

Let realm be module.[[Realm]].

The proposed reading
  1. If module.[[Environment]] is not empty, return unused.
  2. Let realm be module.[[Realm]].
Read as written
The text never stops a run.
Default
The literal text.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum SyntheticModuleLinkResets=READING runs a program under one of them (literal, proposed), and the engine's theorem holds under every choice.

The program tests/run/module_json_relink.js, run as ecma-run --module --module-dir tests/run/modules tests/run/module_json_relink.js with the option of each row:

The literal text (the default)
--erratum SyntheticModuleLinkResets=literal
normal: undefined
  • main sees 1
  • probe sees undefined
  • after other: 1
The proposed reading
--erratum SyntheticModuleLinkResets=proposed
normal: undefined
  • main sees 1
  • probe sees 1
  • after other: 1
Source
// module: yes
// args: --module-dir tests/run/modules
// expect: normal: undefined
// print: main sees 1
// print: probe sees undefined
// print: after other: 1
// Link of a Synthetic Module Record (§16.2.1.8.4.4) runs for every importer
// that is linked (InnerModuleLinking 1.a) and gives the module a new
// environment whose bindings are undefined until it is evaluated again. The
// second importer (modules/relink_other.mjs) imports modules/relink_probe.mjs
// before the JSON module, so the probe runs between the second Link and the
// second evaluation and reads undefined through this module's import. Kept
// literal (Erratum SyntheticModuleLinkResets, docs/spec-issues/15): no
// test262 test evaluates a module in between. Engines print 1.
import j from "./relink.json" with { type: "json" };
export function readJ() { return j; }
print("main sees " + j.a);
import("./relink_other.mjs").then(function () { print("after other: " + j.a); },
  function (e) { print("rejected " + e); });

CreateDynamicFunctionPrivateIdentifiers

default: proposedswitched: spec

Write-up 20. new Function("o", "return o.#f"): no check of private names in dynamic functions

§20.2.1.1.1 CreateDynamicFunction, step 25

If expr is a List of errors, throw a SyntaxError exception.

The test262 reading
  1. If expr is a List of errors, throw a SyntaxError exception.
  2. If AllPrivateIdentifiersValid of body with argument « » is false, throw a SyntaxError exception.
The proposed reading
  1. If expr is a List of errors, throw a SyntaxError exception.
  2. If AllPrivateIdentifiersValid of body with argument « » is false, throw a SyntaxError exception.
  3. If AllPrivateIdentifiersValid of params with argument « » is false, throw a SyntaxError exception.
Default
The proposed reading.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum CreateDynamicFunctionPrivateIdentifiers=READING runs a program under one of them (literal, test262, proposed), and the engine's theorem holds under every choice.

The program tests/run/dynamic_function_private_identifiers.js, run as ecma-run tests/run/dynamic_function_private_identifiers.js with the option of each row:

The proposed reading (the default)
--erratum CreateDynamicFunctionPrivateIdentifiers=proposed
normal: undefined
  • body: SyntaxError
  • params: SyntaxError
  • generator body: SyntaxError
The test262 reading
--erratum CreateDynamicFunctionPrivateIdentifiers=test262
normal: undefined
  • body: SyntaxError
  • params: no error
  • generator body: SyntaxError
The literal text
--erratum CreateDynamicFunctionPrivateIdentifiers=literal
normal: undefined
  • body: no error
  • params: no error
  • generator body: no error

Open in the debugger: The specification Open in the debugger: The specification, with the test262 reading Open in the debugger: The specification, with the literal text Open in the debugger: The literal text

Source
// expect: normal: undefined
// print: body: SyntaxError
// print: params: SyntaxError
// print: generator body: SyntaxError
// CreateDynamicFunction steps 18-29: no goal it parses with applies
// AllPrivateIdentifiersValid (Erratum CreateDynamicFunctionPrivateIdentifiers).
// The default reading, the proposed one, adds after step 25
// "If AllPrivateIdentifiersValid of _body_ with argument « » is false, throw a
// SyntaxError exception" and the same of _params_ (spec/formal/readings.emu):
// engines parse the parameters and the body as one source text and throw for
// both. The test262 reading checks the body only, which is all test262's
// built-ins/Function/private-identifiers-not-empty.js asserts
// (dynamic_function_private_identifiers_test262.js); the literal text checks
// neither (dynamic_function_private_identifiers_literal.js).
try { new Function("o", "return o.#f"); print("body: no error"); }
catch (e) { print("body: " + e.constructor.name); }
try { new Function("a = {}.#g", ""); print("params: no error"); }
catch (e) { print("params: " + e.constructor.name); }
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
try { GeneratorFunction("o", "yield o.#h"); print("generator body: no error"); }
catch (e) { print("generator body: " + e.constructor.name); }

LonePropertyGeneralCategoryAssert

default: test262switched: spec

Write-up 24. CompileToCharSet asks UnicodeMatchPropertyValue for a General_Category value before testing that it is one

§22.2.2.9 Runtime Semantics: CompileToCharSet, step 2

If UnicodeMatchPropertyValue(General_Category, s) is a Unicode property value or property value alias for the General_Category (gc) property listed in PropertyValueAliases.txt, then

The test262 and proposed readings
  1. If s is a Unicode property value or property value alias for the General_Category (gc) property listed in PropertyValueAliases.txt, then
    1. Let v be UnicodeMatchPropertyValue(StringToCodePoints("General_Category"), s).
    2. Return the CharSet containing all Unicode code points whose character database definition includes the property “General_Category” with value v.
Read as written
A run stops at §22.2.2.9.8 UnicodeMatchPropertyValue, step 2, when called from §22.2.2.9 Runtime Semantics: CompileToCharSet.
Default
The test262 reading.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum LonePropertyGeneralCategoryAssert=READING runs a program under one of them (literal, test262, proposed), and the engine's theorem holds under every choice.

The program tests/run/errata_lone_property_gc_assert_literal.js, run as ecma-run tests/run/errata_lone_property_gc_assert_literal.js with the option of each row:

The test262 reading (the default)
--erratum LonePropertyGeneralCategoryAssert=test262
normal: true
The literal text
--erratum LonePropertyGeneralCategoryAssert=literal
stop: erratum LonePropertyGeneralCategoryAssert sec-runtime-semantics-unicodematchpropertyvalue-p-v#0 2: stops at §22.2.2.9.8 UnicodeMatchPropertyValue, step 2 (the step this erratum names)

Open in the debugger: The specification Open in the debugger: The specification, with the literal text

Source
// expect: stop: erratum LonePropertyGeneralCategoryAssert sec-runtime-semantics-unicodematchpropertyvalue-p-v#0 2
// args: --erratum LonePropertyGeneralCategoryAssert=literal
// CompileToCharSet's lone \p{X} (Erratum LonePropertyGeneralCategoryAssert): the
// literal reading passes the String "General_Category" to UnicodeMatchPropertyValue
// and asks it for a binary property's name, and the run stops as the erratum.
/\p{ASCII}/u.test("a");

AllocateSharedArrayBufferByteLengthStore

default: test262switched: spec

Write-up 43. AllocateSharedArrayBuffer stores a growable buffer's length with SetValueInBuffer on a Shared Data Block

§25.2.2.1 AllocateSharedArrayBuffer, step 9.c

Perform SetValueInBuffer(byteLengthBlock, 0, biguint64, ℤ(byteLength), true, seq-cst).

The test262 and proposed readings
  1. Let agentRecord be the Agent Record of the surrounding agent.
  2. Let rawBytes be NumericToRawBytes(biguint64, ℤ(byteLength), agentRecord.[[LittleEndian]]).
  3. Let execution be agentRecord.[[CandidateExecution]].
  4. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
  5. Append WriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: byteLengthBlock, [[ByteIndex]]: 0, [[ElementSize]]: 8, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].

The overlay's note

SetValueInBuffer takes an ArrayBuffer or SharedArrayBuffer (its step 4 reads [[ArrayBufferData]]); byteLengthBlock is a Shared Data Block, which ArrayBufferByteLength and SharedArrayBuffer.prototype.grow read with GetRawBytesFromSharedBlock. The reading writes it as SetValueInBuffer's shared branch would (IsNoTearConfiguration(biguint64, seq-cst) is true). test262 constructs growable SharedArrayBuffers (built-ins/SharedArrayBuffer/prototype/grow).

Default
The test262 reading.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum AllocateSharedArrayBufferByteLengthStore=READING runs a program under one of them (literal, test262, proposed), and the engine's theorem holds under every choice.

The program tests/run/errata_allocate_sab_byte_length.js, run as ecma-run tests/run/errata_allocate_sab_byte_length.js with the option of each row:

The test262 reading (the default)
--erratum AllocateSharedArrayBufferByteLengthStore=test262
normal: 2
The literal text
--erratum AllocateSharedArrayBufferByteLengthStore=literal
stop: sortError sec-setvalueinbuffer#0 4: stops at §25.1.3.18 SetValueInBuffer, step 4 (a value of the wrong sort reaches the step)

Open in the debugger: The specification Open in the debugger: The specification, with the literal text

Source
// expect: normal: 2
// A growable SharedArrayBuffer (Erratum AllocateSharedArrayBufferByteLengthStore): the
// test262 reading stores the byte length in its Shared Data Block, which grow reads.
var b = new SharedArrayBuffer(1, { maxByteLength: 4 });
b.grow(2);
b.byteLength;

ContainsAwaitCover

default: test262switched: spec

Write-up 35. Contains never finds an AwaitExpression: async function f(x = await 1) {} has no early error

§8.5.1 Static Semantics: Contains, step 1.a

If child is an instance of symbol, return true.

The test262 and proposed readings
  1. If child is an instance of symbol, return true.
  2. If symbol is AwaitExpression and this Parse Node is an instance of the production UnaryExpression : CoverAwaitExpressionAndAwaitUsingDeclarationHead, return true.

The overlay's note

An await expression parses as UnaryExpression : CoverAwaitExpressionAndAwaitUsingDeclarationHead, and AwaitExpression is only the cover's refined interpretation, so the default definition never meets an AwaitExpression and every early error rule "X Contains AwaitExpression" holds vacuously. test262 requires them (built-ins/AsyncGeneratorFunction/instance-await-expr-in-param.js, language/expressions/async-generator/early-errors-expression-formals-contains-await-expr.js, language/expressions/async-arrow-function/await-as-param-nested-arrow-body-position.js). The reading counts the cover of that production, and not the cover of an AwaitUsingDeclaration, as an AwaitExpression. The proposed text is the equivalent Contains row for UnaryExpression : CoverAwaitExpressionAndAwaitUsingDeclarationHead: "1. If symbol is AwaitExpression, return true. 2. Let expr be the AwaitExpression that is covered by CoverAwaitExpressionAndAwaitUsingDeclarationHead. 3. Return expr Contains symbol."

Default
The test262 reading.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum ContainsAwaitCover=READING runs a program under one of them (literal, test262, proposed), and the engine's theorem holds under every choice.

The program tests/run/await_in_params_early_errors.js, run as ecma-run tests/run/await_in_params_early_errors.js with the option of each row:

The test262 reading (the default)
--erratum ContainsAwaitCover=test262
normal: undefined
  • async function: SyntaxError
  • async function expression: SyntaxError
  • async generator: SyntaxError
  • async generator expression: SyntaxError
  • async method: SyntaxError
  • async generator method: SyntaxError
  • arrow in async body: SyntaxError
  • async arrow in async body: SyntaxError
  • AsyncFunction: SyntaxError
  • AsyncGeneratorFunction: SyntaxError
  • await in async body: no error
  • static block in async function: no error
  • var await in nested function: no error
  • async arrow parameters: no error
  • await in static block: SyntaxError
  • var await in static block function: no error
The literal text
--erratum ContainsAwaitCover=literal
normal: undefined
  • async function: no error
  • async function expression: no error
  • async generator: no error
  • async generator expression: no error
  • async method: no error
  • async generator method: no error
  • arrow in async body: no error
  • async arrow in async body: no error
  • AsyncFunction: no error
  • AsyncGeneratorFunction: no error
  • await in async body: no error
  • static block in async function: no error
  • var await in nested function: no error
  • async arrow parameters: no error
  • await in static block: SyntaxError
  • var await in static block function: no error

Open in the debugger: The specification Open in the debugger: The specification, with the literal text

Source
// expect: normal: undefined
// print: async function: SyntaxError
// print: async function expression: SyntaxError
// print: async generator: SyntaxError
// print: async generator expression: SyntaxError
// print: async method: SyntaxError
// print: async generator method: SyntaxError
// print: arrow in async body: SyntaxError
// print: async arrow in async body: SyntaxError
// print: AsyncFunction: SyntaxError
// print: AsyncGeneratorFunction: SyntaxError
// print: await in async body: no error
// print: static block in async function: no error
// print: var await in nested function: no error
// print: async arrow parameters: no error
// print: await in static block: SyntaxError
// print: var await in static block function: no error
// The early errors "X Contains |AwaitExpression|" (§15.3.1, §15.6.1, §15.8.1,
// §15.9.1): an `await` expression is the cover of UnaryExpression :
// CoverAwaitExpressionAndAwaitUsingDeclarationHead, which Contains counts as an
// AwaitExpression (Erratum ContainsAwaitCover, its test262 reading).
// Contains does not look into nested functions, and a static block's rule is
// on the terminal `await`.
var AsyncFunction = (async function () {}).constructor;
var AsyncGeneratorFunction = (async function* () {}).constructor;
function check(name, run) {
  try { run(); print(name + ": no error"); }
  catch (e) { print(name + ": " + e.constructor.name); }
}
function script(src) { return function () { (0, eval)(src); }; }
check("async function", script("async function f(x = await 1) {}"));
check("async function expression", script("(async function (x = await 1) {})"));
check("async generator", script("async function* f(x = await 1) {}"));
check("async generator expression", script("(async function* (x = await 1) {})"));
check("async method", script("({ async m(x = await 1) {} })"));
check("async generator method", script("({ async *m(x = await 1) {} })"));
check("arrow in async body", script("async function g() { (x = await 1) => 0; }"));
check("async arrow in async body", script("async function g() { async (x = await 1) => 0; }"));
check("AsyncFunction", function () { AsyncFunction("x = await 1", ""); });
check("AsyncGeneratorFunction", function () { AsyncGeneratorFunction("x = await 1", ""); });
check("await in async body", script("async function h() { await 1; }"));
check("static block in async function", script("(async function () { class C { static { } } })"));
check("var await in nested function", script("async function k(x = function () { var await; }) {}"));
check("async arrow parameters", script("async (x = 1) => await x;"));
check("await in static block", script("class C { static { await 0; } }"));
check("var await in static block function", script("class C { static { (function () { var await; }); } }"));

SplitCodeUnitStrings

default: test262switched: spec

Write-up 37. String.prototype.split with an empty separator builds an Array of code units

§22.1.3.23 String.prototype.split, step 10.d

Let codeUnits be a List consisting of the sequence of code units that are the elements of head.

The test262 and proposed readings
  1. Let codeUnits be a new empty List.
  2. For each integer i such that 0 ≤ i < outLength, in ascending order, do
    1. Append the substring of head from i to i + 1 to codeUnits.

The overlay's note

The literal step passes a List of code units to CreateArrayFromList, whose parameter is a List of ECMAScript language values; a code unit is not one. test262 requires the Array's elements to be the Strings of one code unit each (built-ins/String/prototype/split/separator-empty-string-instance-is-string.js), as the method's description says: "any separator coerced to the empty String splits the this value into individual code units".

Default
The test262 reading.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum SplitCodeUnitStrings=READING runs a program under one of them (literal, test262, proposed), and the engine's theorem holds under every choice.

The program tests/run/errata_split_code_units.js, run as ecma-run tests/run/errata_split_code_units.js with the option of each row:

The test262 reading (the default)
--erratum SplitCodeUnitStrings=test262
normal: "string"
The literal text
--erratum SplitCodeUnitStrings=literal
stop: sortError sec-typeof-operator-runtime-semantics-evaluation#0 13: stops at §13.5.3.1 Runtime Semantics: Evaluation, step 13 (a value of the wrong sort reaches the step)

Open in the debugger: The specification Open in the debugger: The specification, with the literal text

Source
// expect: normal: "string"
// String.prototype.split with the empty String as separator (Erratum SplitCodeUnitStrings):
// the test262 reading makes each element a String of one code unit.
typeof "ab".split("")[1];

RacesNotBoth

default: literalswitched: none

Write-up 23. Races: "it is not the case that both" is always true

§29.8 Races, step 1.a

If it is not the case that both eventA happens-before eventB in execution and eventB happens-before eventA in execution, then

The overlay's note

Step 1.a of Races (sec-races) is always true: an execution's happens-before is a strict partial order, so eventA and eventB never both happen-before each other, and any two conflicting events race. The memory model's meaning (Ecma.MemoryModel.Race) reads the literal text. The proposed text of step 1.a: "If neither eventA happens-before eventB in execution nor eventB happens-before eventA in execution, then".

Read as written
The text never stops a run.
Default
The literal text.
Switched
Nowhere. The overlay holds one reading, and no option changes it.

No program on this site shows this erratum.

InitHappensBeforeOverlap

default: literalswitched: none

Write-up 48. happens-before orders an init write only before events with overlapping ranges, which excludes the equal range of a 1-byte access

§29.6.6 happens-before, the third condition

SharedDataBlockEventSet(execution) contains both eventA and eventB, eventA.[[Order]] is init, and eventA and eventB have overlapping memory ranges.

The overlay's note

The third condition of happens-before orders an init write only before events whose memory ranges are overlapping, and "overlapping" excludes equal ranges, so a 1-byte event at an init event's byte is not ordered after it. The proposed text: "SharedDataBlockEventSet(execution) contains both eventA and eventB, eventA.[[Order]] is init, eventA and eventB are not the same Shared Data Block event, and eventA and eventB do not have disjoint memory ranges."

Read as written
The text never stops a run.
Default
The literal text.
Switched
Nowhere. The overlay holds one reading, and no option changes it.

No program on this site shows this erratum.

MemoryRangeSameBlock

default: proposedswitched: none

Write-up 50. reads-bytes-from and coherent reads ask only for a byte index in a memory range, which names no [[Block]]

§29.6.2 reads-bytes-from

Each event writeEvent with index i in writes has readEvent.[[ByteIndex]] + i in its memory range.

The overlay's note

A memory range is a Set of integers, the byte indices from [[ByteIndex]], with no [[Block]] in it, so reads-bytes-from's "has readEvent.[[ByteIndex]] + i in its memory range" and coherent reads' "has byteLocation in its memory range" (step 1.c.ii) admit a write to another Shared Data Block at the same index. The proposed text, which the memory model's meaning (Ecma.MemoryModel.Rbf.Valid, CoherentReads) reads: "Each event writeEvent with index i in writes has readEvent.[[Block]] as its [[Block]] and readEvent.[[ByteIndex]] + i in its memory range", and in step 1.c.ii "a WriteSharedMemory or ReadModifyWriteSharedMemory event value whose [[Block]] is readEvent.[[Block]] and that has byteLocation in its memory range".

Default
The proposed reading.
Switched
Nowhere. The overlay holds one reading, and no option changes it.

No program on this site shows this erratum.

CreateIntrinsicsAsyncArgument

default: test262switched: spec

Write-up 33. CreateIntrinsics passes async in prefix's position: every built-in gets a Boolean prefix

§9.3.2 CreateIntrinsics, step 2

Set fields of realmRecord.[[Intrinsics]] with the values listed in a table of §6.1.7.4. The field names are the names listed in the “Intrinsic Name” column of the table. The value of each field is a new object value fully and recursively populated with property values as defined by the specification of each object in clauses §19 through §28. All object property values are newly created object values. All values that are built-in function objects are created by performing CreateBuiltinFunction(steps, length, name, slots, realmRecord, proto, async) where steps is the definition of that function provided by this specification, name is the initial value of the function's "name" property, length is the initial value of the function's "length" property, slots is a list of the names, if any, of the function's specified internal slots, proto is the specified value of the function's [[Prototype]] internal slot, and async is true if the function is described as “async” and false otherwise. The creation of the intrinsics and their properties must be ordered to avoid any dependencies upon objects that have not yet been created.

The test262 and proposed readings
  1. Let entries be IntrinsicObjects().
  2. Let objects be a new empty List.
  3. For each Record entry of entries, do
    1. If entry.[[Prototype]] is null, let proto be null; else let proto be objects[entry.[[Prototype]]].
    2. If entry.[[Behaviour]] is not empty, then
      1. If entry.[[Prefix]] is empty, let obj be CreateBuiltinFunction(entry.[[Behaviour]], entry.[[Length]], entry.[[Name]], entry.[[Slots]], realmRecord, proto); else let obj be CreateBuiltinFunction(entry.[[Behaviour]], entry.[[Length]], entry.[[Name]], entry.[[Slots]], realmRecord, proto, entry.[[Prefix]]).
      2. Set obj.[[Async]] to entry.[[Async]].
      3. If entry.[[Constructor]] is true, set obj.[[Construct]] to the definition specified in §10.3.2.
    3. Else,
      1. Let obj be OrdinaryObjectCreate(proto, entry.[[Slots]]).
      2. If entry.[[Exotic]] is §10.4.2, then
        1. Set obj.[[DefineOwnProperty]] as specified in §10.4.2.1.
      3. Else if entry.[[Exotic]] is §10.4.3, then
        1. Set obj.[[GetOwnProperty]] as specified in §10.4.3.1.
        2. Set obj.[[DefineOwnProperty]] as specified in §10.4.3.2.
        3. Set obj.[[OwnPropertyKeys]] as specified in §10.4.3.3.
      4. Else if entry.[[Exotic]] is §10.4.7, then
        1. Set obj.[[SetPrototypeOf]] to the definition specified in §10.4.7.1.
    4. For each Record slot of entry.[[SlotValues]], do
      1. Perform SetFieldNamed(obj, slot.[[Name]], slot.[[Value]]).
    5. For each element name of entry.[[Names]], do
      1. Perform SetFieldNamed(realmRecord.[[Intrinsics]], name, obj).
    6. Append obj to objects.
  4. For each Record entry of entries, do
    1. Let obj be objects[entry.[[Index]]].
    2. If entry.[[Behaviour]] is not empty, then
      1. Let la be entry.[[LengthAttributes]].
      2. Perform ! DefinePropertyOrThrow(obj, "length", PropertyDescriptor { [[Writable]]: la.[[Writable]], [[Enumerable]]: la.[[Enumerable]], [[Configurable]]: la.[[Configurable]] }).
      3. Let na be entry.[[NameAttributes]].
      4. Perform ! DefinePropertyOrThrow(obj, "name", PropertyDescriptor { [[Writable]]: na.[[Writable]], [[Enumerable]]: na.[[Enumerable]], [[Configurable]]: na.[[Configurable]] }).
    3. For each Record p of PropertyOrder(obj, entry.[[Properties]]), do
      1. If PropertyProvided(p) is true, perform OwnPropertyCreate(obj, p.[[Key]], IntrinsicPropertyDescriptor(p, objects), p.[[Kind]]).
    4. Set obj.[[Extensible]] to entry.[[Extensible]].

The overlay's note

Step 2 creates each built-in function by "CreateBuiltinFunction(steps, length, name, slots, realmRecord, proto, async)", which passes async as CreateBuiltinFunction's prefix and gives no accessor its prefix; read literally (realm.emu), SetFunctionName concatenates a Boolean and realm creation stops. test262 requires both: built-ins/Array/fromAsync/ (an async function) and built-ins/Map/prototype/size/name.js ("get size"). The proposed text: "CreateBuiltinFunction(steps, length, name, slots, realmRecord, proto, prefix, async), where prefix is "get" or "set" for a get or set accessor function of a built-in property and empty otherwise", with an empty prefix read as not present.

Read as written
A run stops at §10.2.9 SetFunctionName, step 5.a, when called from §10.3.4 CreateBuiltinFunction.
Default
The test262 reading.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum CreateIntrinsicsAsyncArgument=READING runs a program under one of them (literal, test262, proposed), and the engine's theorem holds under every choice.

The program tests/run/errata_createintrinsics_async_argument.js, run as ecma-run tests/run/errata_createintrinsics_async_argument.js with the option of each row:

The test262 reading (the default)
--erratum CreateIntrinsicsAsyncArgument=test262
normal: "get size|true"
The literal text
--erratum CreateIntrinsicsAsyncArgument=literal
stop: erratum CreateIntrinsicsAsyncArgument sec-setfunctionname#0 5.a: stops at §10.2.9 SetFunctionName, step 5.a (the step this erratum names)

Open in the debugger: The specification Open in the debugger: The specification, with the literal text

Source
// expect: normal: "get size|true"
// CreateIntrinsics step 2 (Erratum CreateIntrinsicsAsyncArgument): the
// test262 reading passes a getter its prefix and Array.fromAsync its [[Async]].
var r = [];
r.push(Object.getOwnPropertyDescriptor(Map.prototype, "size").get.name);
r.push(Array.fromAsync([1]) instanceof Promise);
r.join("|");

SortInfiniteComparator

default: test262switched: spec

Write-up 31. Sort: a comparator that returns ±∞ is neither consistent nor inconsistent

§23.1.3.30.1 SortIndexedProperties, step 4

Sort items using an implementation-defined sequence of calls to sortCompare. If any such call returns an abrupt completion, stop before performing any further calls to sortCompare and return that Completion Record.

The test262 and proposed readings
  1. Let next be SortStep(the number of elements in items, empty, empty).
  2. Repeat, while next is a List,
    1. Let result be sortCompare(items[next[0]], items[next[1]]).
    2. If result is an abrupt completion, return result.
    3. Set next to SortStep(the number of elements in items, next[2], result).
  3. Let sorted be a new empty List.
  4. For each element i of next.[[Value]], do
    1. Append items[i] to sorted.
  5. Set items to sorted.

The overlay's note

The definition of a consistent comparator reads each result as ℝ(comparator(a, b)), which has no value for ±∞; the literal reading (sort.emu) stops there. No test262 test has a comparator return ±∞. The test262 reading has no ℝ step: by SortStep's law (sort.emu) no consistent comparator gives a ±∞ result, so the order is the host's, and both test hosts order by the result's sign. The proposed text compares the Number itself with +0𝔽 where the text takes ℝ of it, in the sort order's two conditions ("if sortCompare(old[j], old[k]) < +0𝔽", "… = +0𝔽") and in the definition of a consistent comparator ("a <C b means comparator(a, b) < +0𝔽", likewise for =C and >C).

Default
The test262 reading.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum SortInfiniteComparator=READING runs a program under one of them (literal, test262, proposed), and the engine's theorem holds under every choice.

The program tests/run/errata_sort_infinite_comparator.js, run as ecma-run tests/run/errata_sort_infinite_comparator.js with the option of each row:

The test262 reading (the default)
--erratum SortInfiniteComparator=test262
normal: "1,2,3|3,2,1"
The literal text
--erratum SortInfiniteComparator=literal
stop: sortError sec-sortindexedproperties#0 4..ccxlii.2.c: stops at §23.1.3.30.1 SortIndexedProperties, step 4 (inside the reading of that step) (a value of the wrong sort reaches the step)

Open in the debugger: The specification Open in the debugger: The specification, with the literal text Open in the debugger: The literal text

Source
// expect: normal: "1,2,3|3,2,1"
// A comparator that returns ±Infinity (Erratum SortInfiniteComparator): under
// the test262 reading the order is the host's, and the test host's goes by the
// result's sign.
var r = [];
r.push([3, 1, 2].sort(function (a, b) { return a < b ? -Infinity : a > b ? Infinity : 0; }).join());
r.push([1, 3, 2].sort(function (a, b) { return a < b ? Infinity : a > b ? -Infinity : 0; }).join());
r.join("|");

UnregisterIteratesCopy

default: test262switched: spec

Write-up 45. FinalizationRegistry.prototype.unregister removes cells from the List it iterates

§26.2.3.3 FinalizationRegistry.prototype.unregister, step 5

For each Record { [[WeakRefTarget]], [[HeldValue]], [[UnregisterToken]] } cell of finalizationRegistry.[[Cells]], do

The test262 and proposed readings
  1. Let cells be a copy of finalizationRegistry.[[Cells]].
  2. For each Record { [[WeakRefTarget]], [[HeldValue]], [[UnregisterToken]] } cell of cells, do
    1. If cell.[[UnregisterToken]] is not empty and SameValue(cell.[[UnregisterToken]], unregisterToken) is true, then
      1. Remove cell from finalizationRegistry.[[Cells]].
      2. Set removed to true.

The overlay's note

The literal step removes from the List it iterates, and the For each convention does not say which element comes next; read literally, the cell after a removed one is skipped. test262 requires every cell with the token to go (built-ins/FinalizationRegistry/prototype/unregister/unregister-object-token.js and unregister-symbol-token.js register two cells with one token in a row). The proposed text iterates a copy, as above.

Read as written
The text never stops a run.
Default
The test262 reading.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum UnregisterIteratesCopy=READING runs a program under one of them (literal, test262, proposed), and the engine's theorem holds under every choice.

The program tests/run/errata_unregister_two_cells.js, run as ecma-run tests/run/errata_unregister_two_cells.js with the option of each row:

The test262 reading (the default)
--erratum UnregisterIteratesCopy=test262
normal: "true|false"
The literal text
--erratum UnregisterIteratesCopy=literal
normal: "true|true"

Open in the debugger: The specification Open in the debugger: The specification, with the literal text Open in the debugger: The literal text

Source
// expect: normal: "true|false"
// Two cells with one unregister token, in a row (Erratum
// UnregisterIteratesCopy): the test262 reading removes both.
var fr = new FinalizationRegistry(function () {});
var token = {};
fr.register({}, 1, token);
fr.register({}, 2, token);
[fr.unregister(token), fr.unregister(token)].join("|");

IsCharacterClassControlLetter

default: test262switched: spec

Write-up 49. Annex B: /[\c1-\c5]/ asks for the IsCharacterClass of ClassEscape :: c ClassControlLetter, which has none

§B.1.2.3 Static Semantics: IsCharacterClass has no row for ClassEscape :: `c` ClassControlLetter.

The test262 and proposed readings
  1. Return false.

The overlay's note

IsCharacterClass has no definition for this production of §B.1.2, whose CharacterValue §B.1.2.4 gives, and §B.1.2.1's range rules ask for it of every ClassAtom of a range: /[\c1-\c5]/. The literal text stops there (it asks IsCharacterClass of ClassControlLetter, which has no definition either). The row is the twin of ClassEscape :: CharacterEscape's: the escape is one character. No test262 test has \c and a digit or _ at a range's end; annexB/language/literals/regexp/class-escape.js reads [\c1] as U+0011.

Default
The test262 reading.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum IsCharacterClassControlLetter=READING runs a program under one of them (literal, test262, proposed), and the engine's theorem holds under every choice.

The program tests/run/errata_ischaracterclass_control_letter.js, run as ecma-run --annex-b sec-regular-expressions-patterns tests/run/errata_ischaracterclass_control_letter.js with the option of each row:

The test262 reading (the default)
--erratum IsCharacterClassControlLetter=test262
normal: true
The literal text
--erratum IsCharacterClassControlLetter=literal
stop: sortError row-ischaracterclass-classcontrolletter#0 1: stops at row-ischaracterclass-classcontrolletter (a reading of the overlay), step 1 (a value of the wrong sort reaches the step)

Open in the debugger: The specification Open in the debugger: The specification, with the literal text

Source
// expect: normal: true
// args: --annex-b sec-regular-expressions-patterns
// A class range between two \c escapes of B.1.2 (Erratum IsCharacterClassControlLetter):
// the test262 reading gives IsCharacterClass a row for ClassEscape :: `c` ClassControlLetter.
/[\c1-\c5]/.test("\x11");

StringMaximumLength

default: proposedswitched: spec

Write-up 53. Maximum String length is unspecified and leaves "a".repeat(2 ** 30) exact up to 2^53 - 1

§22.1.3.18 String.prototype.repeat, step 7

Return the String value that is made from n copies of string appended together.

The proposed reading
  1. If StringTooLarge(n × the length of string) is true, throw a RangeError exception.
  2. Return the String value that is made from n copies of string appended together.
§22.1.3.17.1 StringPaddingBuiltinsImpl, step 7

Return StringPad(string, intMaxLength, fillString, placement).

The proposed reading
  1. If fillString is not the empty String and StringTooLarge(intMaxLength) is true, throw a RangeError exception.
  2. Return StringPad(string, intMaxLength, fillString, placement).
§22.1.3.5 String.prototype.concat, step 5.b

Set result to the string-concatenation of result and nextString.

The proposed reading
  1. If StringTooLarge(the length of result + the length of nextString) is true, throw a RangeError exception.
  2. Set result to the string-concatenation of result and nextString.
§13.15.3 ApplyStringOrNumericBinaryOperator, step 1.c.iii

Return the string-concatenation of leftString and rightString.

The proposed reading
  1. If StringTooLarge(the length of leftString + the length of rightString) is true, throw a RangeError exception.
  2. Return the string-concatenation of leftString and rightString.
§23.1.3.18.1 JoinIndexedProperties, step 4.a

If k > 0, set result to the string-concatenation of result and separator.

The proposed reading
  1. If k > 0, then
    1. If StringTooLarge(the length of result + the length of separator) is true, throw a RangeError exception.
    2. Set result to the string-concatenation of result and separator.
§23.1.3.18.1 JoinIndexedProperties, step 4.d.iii

Set result to the string-concatenation of result and elementString.

The proposed reading
  1. If StringTooLarge(the length of result + the length of elementString) is true, throw a RangeError exception.
  2. Set result to the string-concatenation of result and elementString.

The overlay's note

§6.1.4 defines the String type as sequences of up to 253 - 1 16-bit code units and leaves the operations' behaviour unspecified when a result would exceed an implementation's smaller maximum String length; every engine throws a RangeError past its limit (V8 228 on 32-bit targets and 229 - 24 on 64-bit, SpiderMonkey 230 - 2, JavaScriptCore 231 - 1). The proposed text checks StringTooLarge before constructing the String and throws a RangeError exception when true (write-up 53).

Default
The proposed reading.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum StringMaximumLength=READING runs a program under one of them (literal, proposed), and the engine's theorem holds under every choice.

No program on this site shows this erratum.

MVDecimalIntegerLiteralZero

default: literalswitched: none

Write-up 52. Static Semantics: MV has a row for ` DecimalIntegerLiteral :: 0 `, a production the grammar does not have

§12.9.3.2 Static Semantics: MV, an equation row

The MV of DecimalIntegerLiteral :: `0` is 0.

The overlay's note

§12.9.3 defines DecimalIntegerLiteral as "DecimalDigit", "NonZeroDigit NumericLiteralSeparator? DecimalDigits[+Sep]" and "NonOctalDecimalIntegerLiteral", and has no production DecimalIntegerLiteral :: `0`; §12.9.3.2 MV still has the row "The MV of DecimalIntegerLiteral :: `0` is 0." The row names no production of the grammar, so it is never applied: the MV of the literal 0 is that of DecimalIntegerLiteral :: DecimalDigit, the MV of its DecimalDigit, which is 0. Both readings agree. The proposed text: delete the row (write-up 52).

Read as written
The text never stops a run.
Default
The literal text.
Switched
Nowhere. The overlay holds one reading, and no option changes it.

No program on this site shows this erratum.

Proposed normative changes (2)

Not a defect: the text is consistent, and the change would alter what it requires.

ErratumClauseDefaultSwitchedProgram
IdentityEscapeJoinControls22.2.1 Patternstest262specyes
BigIntMaximumSize6.1.6.2.3 BigInt::exponentiateproposedspecyes

IdentityEscapeJoinControls

default: test262switched: spec

Write-up 21. /\<ZWNJ>/ and /\<ZWJ>/ became SyntaxErrors with Unicode 15.1

§22.2.1 Patterns, the definition of IdentityEscape
IdentityEscape[UnicodeMode] ::
  [+UnicodeMode] SyntaxCharacter
  [+UnicodeMode] `/`
  [~UnicodeMode] SourceCharacter but not UnicodeIDContinue
The test262 and proposed readings
IdentityEscape[UnicodeMode] ::
  [+UnicodeMode] SyntaxCharacter
  [+UnicodeMode] `/`
  [~UnicodeMode] SourceCharacter but not UnicodeIDContinue
  [~UnicodeMode] `‌`
  [~UnicodeMode] `‍`

The overlay's note

Since Unicode 15.1 added <ZWNJ> (U+200C) and <ZWJ> (U+200D) to ID_Continue, IdentityEscape[~UnicodeMode] :: SourceCharacter but not UnicodeIDContinue makes /\\‌/ and /\\‍/ SyntaxErrors outside §B.1.2 without an Annex F record; the test262 and proposed reading aligns the main grammar with §B.1.2 and pre-15.1 behaviour by admitting both code points as identity escapes (write-up 21).

Default
The test262 reading.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum IdentityEscapeJoinControls=READING runs a program under one of them (literal, test262, proposed), and the engine's theorem holds under every choice.

The program tests/run/regexp_identity_escape_join_controls.js, run as ecma-run tests/run/regexp_identity_escape_join_controls.js with the option of each row:

The proposed reading
--erratum IdentityEscapeJoinControls=proposed
normal: undefined
  • U+200C: literal true, class true, a-literal true, RegExp true, u SyntaxError, v SyntaxError
  • U+200D: literal true, class true, a-literal true, RegExp true, u SyntaxError, v SyntaxError
  • U+200B: literal true, class true, a-literal true, RegExp true, u SyntaxError, v SyntaxError
  • U+200E: literal true, class true, a-literal true, RegExp true, u SyntaxError, v SyntaxError
  • U+61: literal SyntaxError, class SyntaxError, a-literal SyntaxError, RegExp SyntaxError, u SyntaxError, v SyntaxError
  • U+B7: literal SyntaxError, class SyntaxError, a-literal SyntaxError, RegExp SyntaxError, u SyntaxError, v SyntaxError
The literal text
--erratum IdentityEscapeJoinControls=literal
normal: undefined
  • U+200C: literal SyntaxError, class SyntaxError, a-literal SyntaxError, RegExp SyntaxError, u SyntaxError, v SyntaxError
  • U+200D: literal SyntaxError, class SyntaxError, a-literal SyntaxError, RegExp SyntaxError, u SyntaxError, v SyntaxError
  • U+200B: literal true, class true, a-literal true, RegExp true, u SyntaxError, v SyntaxError
  • U+200E: literal true, class true, a-literal true, RegExp true, u SyntaxError, v SyntaxError
  • U+61: literal SyntaxError, class SyntaxError, a-literal SyntaxError, RegExp SyntaxError, u SyntaxError, v SyntaxError
  • U+B7: literal SyntaxError, class SyntaxError, a-literal SyntaxError, RegExp SyntaxError, u SyntaxError, v SyntaxError

Open in the debugger: The specification Open in the debugger: The specification, with the proposed reading Open in the debugger: The specification, with the literal text

Source
// Erratum IdentityEscapeJoinControls, at its test262 reading: without the
// u or v flag, `\` U+200C (ZWNJ) and `\` U+200D (ZWJ) are IdentityEscapes,
// as test262's language/literals/regexp/S7.8.5_A1.4_T2.js and
// S7.8.5_A2.4_T2.js require, although Unicode 15.1 made both UnicodeIDContinue.
// ecma-run's default host does not support §B.1.2, so this is the main grammar:
// the other UnicodeIDContinue code points (`a`, U+00B7) stay SyntaxErrors, and
// U+200B and U+200E (not ID_Continue) are IdentityEscapes. The u and v flags
// allow neither. The characters are invisible: the patterns are built with
// fromCharCode.
// expect: normal: undefined
// print: U+200C: literal true, class true, a-literal true, RegExp true, u SyntaxError, v SyntaxError
// print: U+200D: literal true, class true, a-literal true, RegExp true, u SyntaxError, v SyntaxError
// print: U+200B: literal true, class true, a-literal true, RegExp true, u SyntaxError, v SyntaxError
// print: U+200E: literal true, class true, a-literal true, RegExp true, u SyntaxError, v SyntaxError
// print: U+61: literal SyntaxError, class SyntaxError, a-literal SyntaxError, RegExp SyntaxError, u SyntaxError, v SyntaxError
// print: U+B7: literal SyntaxError, class SyntaxError, a-literal SyntaxError, RegExp SyntaxError, u SyntaxError, v SyntaxError
function t(f) { try { return f(); } catch (e) { return e.name; } }
for (var cu of [0x200C, 0x200D, 0x200B, 0x200E, 0x61, 0xB7]) {
  var ch = String.fromCharCode(cu), src = "\\" + ch;
  print("U+" + cu.toString(16).toUpperCase() + ": " + [
    "literal " + t(() => { var re = eval("/" + src + "/"); return re.source === src && re.test(ch) && !re.test("x"); }),
    "class " + t(() => eval("/[" + src + "]/").test(ch)),
    "a-literal " + t(() => eval("/a" + src + "/").test("a" + ch)),
    "RegExp " + t(() => new RegExp(src).exec("x" + ch)[0] === ch),
    "u " + t(() => new RegExp(src, "u")),
    "v " + t(() => new RegExp(src, "v")),
  ].join(", "));
}

BigIntMaximumSize

default: proposedswitched: spec

Write-up 51. A maximum BigInt size: 2n ** (2n ** 40n) has an exact result in the text, which allows no maximum size

§6.1.6.2.3 BigInt::exponentiate, step 3

Return base raised to the power exponent.

The proposed reading
  1. If BigIntTooLarge("exponentiate", base, exponent) is true, throw a RangeError exception.
  2. Return base raised to the power exponent.
§6.1.6.2.9 BigInt::leftShift, step 2

Return x × 2ℤy.

The proposed reading
  1. If x is 0ℤ or y is 0ℤ, return x.
  2. If BigIntTooLarge("leftShift", x, y) is true, throw a RangeError exception.
  3. Return x × 2ℤy.
§6.1.6.2.4 BigInt::multiply, step 1

Return x × y.

The proposed reading
  1. If BigIntTooLarge("multiply", x, y) is true, throw a RangeError exception.
  2. Return x × y.
§6.1.6.2.7 BigInt::add, step 1

Return x + y.

The proposed reading
  1. If BigIntTooLarge("add", x, y) is true, throw a RangeError exception.
  2. Return x + y.
§6.1.6.2.8 BigInt::subtract, step 1

Return x - y.

The proposed reading
  1. If BigIntTooLarge("subtract", x, y) is true, throw a RangeError exception.
  2. Return x - y.
§21.2.2.2 BigInt.asUintN, step 3

Return ℤ(ℝ(bigint) modulo 2bits).

The proposed reading
  1. If bits = 0 or bigint is 0ℤ, return 0ℤ.
  2. If bigint > 0ℤ and bits ≥ 4 × (DecimalExponent(ℝ(bigint)) + 1), return bigint.
  3. If BigIntTooLarge("asUintN", bigint, ℤ(bits)) is true, throw a RangeError exception.
  4. Return ℤ(ℝ(bigint) modulo 2bits).

The overlay's note

§6.1.6.2 says a BigInt "may be any size and is not limited to a particular bit-width", and BigInt::exponentiate, BigInt::leftShift, BigInt::multiply, BigInt::add, BigInt::subtract and BigInt.asUintN return their exact results whatever their size; every implementation has a maximum size and throws a RangeError past it (V8 at 230 bits). The proposed text, in each of the six before its result is formed: "If the result would exceed the implementation's maximum BigInt size, throw a RangeError exception." The host says whether it would (BigIntTooLarge). The literal text forms the result whatever its size, so an implementation gives up at a limit of its own. Not a defect of the text: a proposed normative change, which says what every implementation does (write-up 51).

Default
The proposed reading.
Switched
In the specification, at run time. Its readings are a parameter of the specification's machine: ecma-run --erratum BigIntMaximumSize=READING runs a program under one of them (literal, proposed), and the engine's theorem holds under every choice.

The program tests/run/bigint_huge_left_shift.js, run as ecma-run tests/run/bigint_huge_left_shift.js with the option of each row:

The proposed reading (the default)
--erratum BigIntMaximumSize=proposed
throw: RangeError
The literal text
--erratum BigIntMaximumSize=literal
stop: implLimit sec-numeric-types-bigint-leftShift#0 2..cclxxviii.2: stops at §6.1.6.2.9 BigInt::leftShift, step 2 (inside the reading of that step) (an implementation limit of the engine)

Open in the debugger: The specification Open in the debugger: The specification, with the literal text

Source
// expect: throw: RangeError
// BigInt::leftShift whose result has more than 2^30 bits throws a RangeError
// (erratum BigIntMaximumSize, proposed reading), not a runtime abort
// (BigInt.shiftLeft).
2n << (1n << 64n);

Removed because the editors fixed the text (5)

Errata an earlier review of the overlay held, and removed when the text at b1eaed82f no longer had the defect. Their ids stay retired in spec/formal/erratum-ids.txt.