test262 is the ECMAScript conformance suite, and JavaScript's oracle here (ROADMAP item 6;
tsc remains the oracle for TypeScript-only syntax, CORRECTNESS.md). Every test under
test/language/ and test/annexB/language/ is parsed by the interpreter over javascript.ts, and its
verdict compared with the one the test's front matter states: a test whose negative.phase is parse
must not parse; every other test must (a resolution or runtime error still parses). The sources are read
from a checkout, never run, never copied into this repository. The harness and its rules:
test/test262.ts; the classes: test/test262-classes.ts;
every disagreeing file: test/test262-record.txt. The gate conformance/test262
fails when either is stale; node test/test262.ts --write re-records.
Corpus: tc39/test262@ebf6ae620a0f292b4845cd4099cb9096735e64ae (pin: test/test262.sha) · 24677 tests (4477 parse-negative) · 283 _FIXTURE.js modules skipped (imported by tests, not tests).
Goal and mode: javascript.ts has one entry, Program, and no script / module goal or strict mode switch
(the [Await] / [Yield] contexts are its only parameters). So it gives every run of a test the same verdict:
a test that test262 runs both sloppy and strict, or only in one mode, or as a module, is parsed once (the
first run's text: "use strict"; prepended for onlyStrict). What depends on the goal or the mode is a class
of its own below (needs-parameter).
21777 of 24677 agree (88.2%).
| directory | files | agree-accept | agree-reject | WE-ACCEPT | WE-REJECT | crash |
|---|---|---|---|---|---|---|
arguments-object |
263 | 262 | 0 | 1 | 0 | 0 |
asi |
102 | 67 | 34 | 1 | 0 | 0 |
block-scope |
145 | 43 | 7 | 95 | 0 | 0 |
comments |
52 | 27 | 25 | 0 | 0 | 0 |
computed-property-names |
48 | 48 | 0 | 0 | 0 | 0 |
destructuring |
19 | 19 | 0 | 0 | 0 | 0 |
directive-prologue |
62 | 51 | 0 | 11 | 0 | 0 |
eval-code |
347 | 347 | 0 | 0 | 0 | 0 |
export |
3 | 0 | 3 | 0 | 0 | 0 |
expressions |
11156 | 9110 | 748 | 1294 | 4 | 0 |
function-code |
217 | 217 | 0 | 0 | 0 | 0 |
future-reserved-words |
55 | 29 | 8 | 18 | 0 | 0 |
global-code |
42 | 28 | 0 | 14 | 0 | 0 |
identifier-resolution |
14 | 13 | 1 | 0 | 0 | 0 |
identifiers |
268 | 152 | 43 | 73 | 0 | 0 |
import |
129 | 119 | 9 | 1 | 0 | 0 |
keywords |
25 | 0 | 25 | 0 | 0 | 0 |
line-terminators |
41 | 24 | 17 | 0 | 0 | 0 |
literals |
536 | 215 | 119 | 202 | 0 | 0 |
module-code |
599 | 433 | 57 | 109 | 0 | 0 |
punctuators |
11 | 1 | 10 | 0 | 0 | 0 |
reserved-words |
27 | 14 | 6 | 7 | 0 | 0 |
rest-parameters |
11 | 10 | 0 | 1 | 0 | 0 |
source-text |
1 | 1 | 0 | 0 | 0 | 0 |
statementList |
80 | 80 | 0 | 0 | 0 | 0 |
statements |
9399 | 7885 | 463 | 1051 | 0 | 0 |
types |
113 | 102 | 7 | 4 | 0 | 0 |
white-space |
67 | 61 | 6 | 0 | 0 | 0 |
annexB/comments |
8 | 0 | 0 | 0 | 8 | 0 |
annexB/eval-code |
469 | 469 | 0 | 0 | 0 | 0 |
annexB/expressions |
26 | 25 | 0 | 1 | 0 | 0 |
annexB/function-code |
159 | 159 | 0 | 0 | 0 | 0 |
annexB/global-code |
153 | 153 | 0 | 0 | 0 | 0 |
annexB/literals |
8 | 8 | 0 | 0 | 0 | 0 |
annexB/statements |
22 | 16 | 1 | 5 | 0 | 0 |
| total | 24677 | 20188 | 1589 | 2888 | 12 | 0 |
WE-ACCEPT: test262 says SyntaxError, the grammar parses. WE-REJECT: test262 parses, the grammar rejects.
Every disagreement has one cause class, the first whose predicate holds (the order of
test/test262-classes.ts); each class was read on a sample of its files. Verdicts: grammar bug (no goal
or mode derives it, or derivable syntax refused); adding (valid syntax the grammar lacks, decided to add);
needs-parameter (the script / module goal, strict mode, [Return] or another parameterised production the
engine lacks: roadmap item 4); early error (a static-semantic rule: not the context-free grammar's,
CORRECTNESS.md, but a checker's over the tree, which is not built; see "Early errors" below).
"acorn agrees": acorn, a production parser that implements most early errors, gets these files right (in every
run); where it does not, the rule is outside even its syntactic layer.
| class | files | acorn agrees | verdict | witnesses |
|---|---|---|---|---|
reject/lexer-division-after-object-literal: a / after an object literal's } is lexed as a regular expression |
2 | 2 | grammar bug: fix | language/expressions/division/bigint-toprimitive.jslanguage/expressions/division/bigint-wrapped-values.js |
reject/lexer-optional-chain-before-digit: ?. before a decimal digit is ? and a number |
1 | 1 | grammar bug: fix | language/expressions/optional-chaining/punctuator-decimal-lookahead.js |
reject/optional-chain-bracket-comma-expression: an optional chain's computed member takes an Expression, comma included |
1 | 1 | grammar bug: fix | language/expressions/optional-chaining/optional-chain-prod-expression.js |
reject/annexb-html-comments: HTML-like comments (Annex B) |
8 | 8 | needs a parameterised production the engine lacks (roadmap item 4) | annexB/language/comments/multi-line-html-close.jsannexB/language/comments/single-line-html-close-first-line-1.jsannexB/language/comments/single-line-html-close-unicode-separators.js |
| verdict | files |
|---|---|
| grammar bug: fix | 4 |
| needs a parameterised production the engine lacks (roadmap item 4) | 8 |
reject/lexer-division-after-object-literal—f({ a: 1 } / 2n, "/"): after a}the lexer reads/as a regular expression (a}that ends a block or a function body is followed by a regex), but this}ends an object literal, a value. Which}it is, is the parser's knowledge: the lexer's regex / division choice needs that context (the lexer lane's; the/after a hex / octal / binary number was the same class's other cause, fixed).reject/lexer-optional-chain-before-digit—true ?.30 : false: OptionalChainingPunctuator is?. [lookahead ∉ DecimalDigit].reject/optional-chain-bracket-comma-expression—a?.[0, 1]: OptionalChain?. [ Expression ]. Every other computed member takes the comma list (bracketIndex); this one waits on TypeScript's v1 ESTree shape (test/fixtures/shape-typescript.ts estreeOptionalChain and its Rust stream type), which tells the branch from a call by its kids.reject/annexb-html-comments—<!--and a line-leading-->are comments in script code only; in module code they are not comments (a <!--bisa < !--bthere). Without the script / module goal, accepting them changes the meaning of valid module code.
| class | files | acorn agrees | verdict | witnesses |
|---|---|---|---|---|
accept/rest-element-shape: a rest element with an initializer, a trailing comma, or a follower |
345 | 345 | grammar bug: fix | language/expressions/arrow-function/dflt-params-rest.jslanguage/expressions/class/gen-method-static/rest-params-trailing-comma-early-error.jslanguage/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-not-final-obj.js |
accept/await-yield-identifier-reference: await / yield as an identifier reference or a label where the context forbids it |
53 | 53 | grammar bug: fix | language/expressions/assignment/dstr/obj-id-identifier-yield-expr.jslanguage/expressions/class/elements/async-gen-private-method/yield-as-label-identifier.jslanguage/statements/class/async-gen-method-static/yield-as-label-identifier.js |
accept/import-export-not-top-level: an import / export declaration inside a statement or expression |
52 | 52 | grammar bug: fix | language/module-code/parse-err-decl-pos-export-arrow-function.jslanguage/module-code/parse-err-decl-pos-export-object-method.jslanguage/module-code/parse-err-decl-pos-import-class-expr-meth-gen.js |
accept/for-in-of-initializer: an initializer in a for-in / for-of head |
31 | 31 | grammar bug: fix | language/block-scope/syntax/for-in/disallow-initialization-assignment.jslanguage/statements/for-await-of/head-let-init.jslanguage/statements/for-of/dstr/var-obj-ptrn-init-err.js |
accept/using-binding-pattern: a binding pattern in a using / await using declaration list |
7 | 7 | grammar bug: fix | language/statements/await-using/syntax/await-using-invalid-arraybindingpattern-after-bindingidentifier.jslanguage/statements/await-using/syntax/await-using-invalid-objectbindingpattern.jslanguage/statements/using/syntax/using-invalid-arraybindingpattern.js |
accept/declaration-in-statement-position: a declaration where only a Statement may stand |
6 | 6 | grammar bug: fix | language/statements/await-using/syntax/with-initializer-case-expression-statement-list.jslanguage/statements/const/syntax/without-initializer-case-expression-statement-list.jslanguage/statements/using/syntax/with-initializer-case-expression-statement-list.js |
accept/restricted-production-line-break: a line break where a production says [no LineTerminator here] |
6 | 6 | grammar bug: fix | language/asi/S7.9_A4.jslanguage/expressions/arrow-function/syntax/early-errors/asi-restriction-invalid-parenless-parameters.jslanguage/expressions/async-arrow-function/early-errors-arrow-formals-lineterminator.js |
accept/coalesce-mixed-with-logical: ?? mixed with && / || without parentheses |
4 | 4 | grammar bug: fix | language/expressions/coalesce/cannot-chain-head-with-logical-and.jslanguage/expressions/coalesce/cannot-chain-head-with-logical-or.jslanguage/expressions/coalesce/cannot-chain-tail-with-logical-and.js |
accept/accessor-parameters: a getter with a parameter |
3 | 3 | grammar bug: fix | language/expressions/class/getter-param-dflt.jslanguage/expressions/object/getter-param-dflt.jslanguage/statements/class/getter-param-dflt.js |
accept/numeric-literal-lexical: a numeric literal the lexical grammar does not derive |
3 | 3 | grammar bug: fix | language/literals/numeric/numeric-separators/numeric-separator-literal-dil-dot-nsl-dd-err.jslanguage/literals/numeric/numeric-separators/numeric-separator-literal-dil-dot-nsl-ep-err.jslanguage/literals/numeric/numeric-separators/numeric-separator-literal-dil-dot-nsl-err.js |
accept/switch-statement-outside-clause: a statement in a switch body before any case |
1 | 1 | grammar bug: fix | language/statements/switch/S12.11_A3_T5.js |
accept/strict-mode: strict mode code |
397 | 397 | needs a parameterised production the engine lacks (roadmap item 4) | language/arguments-object/10.5-1gs.jslanguage/expressions/function/name-arguments-strict.jslanguage/statements/class/elements/gen-private-method/yield-identifier-spread-strict.js |
accept/module-goal: module code |
32 | 32 | needs a parameterised production the engine lacks (roadmap item 4) | language/expressions/class/class-name-ident-await-module.jslanguage/module-code/early-new-target.jslanguage/module-code/export-expname-unpaired-surrogate.js |
accept/return-outside-function: return outside a function |
13 | 13 | needs a parameterised production the engine lacks (roadmap item 4) | language/global-code/return.jslanguage/statements/return/S12.9_A1_T10.jslanguage/statements/return/S12.9_A1_T5.js |
accept/private-names: private names |
346 | 346 | early error: a checker over the tree, not the grammar: not built | language/expressions/class/elements/fields-duplicate-privatenames.jslanguage/expressions/class/elements/syntax/early-errors/grammar-privatename-in-computed-property-missing.jslanguage/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-gen.js |
accept/assignment-target: an invalid assignment target, or a literal that does not cover an AssignmentPattern |
319 | 319 | early error: a checker over the tree, not the grammar: not built | language/expressions/assignment/dstr/array-elem-nested-array-invalid.jslanguage/expressions/assignmenttargettype/parenthesized-equalityexpression-abstract-not-equal-relationalexpression-2.jslanguage/expressions/assignmenttargettype/parenthesized-updateexpression-star-star-exponentiationexpression-1.js |
accept/escaped-keyword: a keyword written with a Unicode escape |
304 | 304 | early error: a checker over the tree, not the grammar: not built | language/expressions/arrow-function/dstr/syntax-error-ident-ref-break-escaped.jslanguage/expressions/class/async-gen-method/yield-as-identifier-reference-escaped.jslanguage/identifiers/val-in-via-escape-hex4.js |
accept/duplicate-bindings: duplicate or conflicting declarations |
248 | 248 | early error: a checker over the tree, not the grammar: not built | language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-async-function.jslanguage/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-generator.jslanguage/statements/class/syntax/early-errors/class-definition-evaluation-block-duplicate-binding.js |
accept/regexp-pattern: a regular expression's pattern or flags |
170 | 170 | early error: a checker over the tree, not the grammar: not built | language/literals/regexp/early-err-arithmetic-modifiers-add-remove-i.jslanguage/literals/regexp/early-err-arithmetic-modifiers-should-not-unicode-case-fold-i.jslanguage/literals/regexp/named-groups/invalid-incomplete-groupname-2.js |
accept/super-new-target: super and new.target outside their contexts |
154 | 154 | early error: a checker over the tree, not the grammar: not built | language/expressions/assignment/target-cover-newtarget.jslanguage/expressions/class/elements/syntax/early-errors/grammar-special-meth-contains-super-private-method.jslanguage/statements/class/elements/nested-comp-name-init-err-contains-super.js |
accept/use-strict-with-non-simple-parameters: "use strict" in a function with a non-simple parameter list |
110 | 110 | early error: a checker over the tree, not the grammar: not built | language/expressions/arrow-function/array-destructuring-param-strict-body.jslanguage/expressions/class/gen-method-static/rest-param-strict-body.jslanguage/statements/async-function/rest-param-strict-body.js |
accept/await-yield-binding-identifier: await / yield as a binding name in an async function / generator |
72 | 72 | early error: a checker over the tree, not the grammar: not built | language/expressions/async-arrow-function/await-as-binding-identifier.jslanguage/expressions/class/elements/gen-private-method-static/yield-as-binding-identifier.jslanguage/statements/class/async-method/await-as-binding-identifier.js |
accept/arguments-in-class-field: arguments in a class field initializer |
58 | 58 | early error: a checker over the tree, not the grammar: not built | language/expressions/class/elements/arrow-fnc-init-err-contains-arguments.jslanguage/expressions/class/elements/private-literal-name-init-err-contains-arguments.jslanguage/statements/class/elements/nested-private-ternary-init-err-contains-arguments.js |
accept/labels-break-continue: labels, break and continue |
53 | 53 | early error: a checker over the tree, not the grammar: not built | language/expressions/async-generator/early-errors-expression-label-name-await.jslanguage/statements/continue/S12.7_A1_T2.jslanguage/statements/for-of/labelled-fn-stmt-lhs.js |
accept/class-element-names: class elements named constructor / prototype |
44 | 44 | early error: a checker over the tree, not the grammar: not built | language/expressions/class/elements/fields-literal-name-propname-constructor.jslanguage/expressions/class/elements/syntax/early-errors/grammar-static-gen-meth-prototype.jslanguage/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-async-gen.js |
accept/await-yield-in-parameters: an await / yield expression in formal parameters |
20 | 20 | early error: a checker over the tree, not the grammar: not built | language/expressions/async-arrow-function/await-as-param-nested-arrow-body-position.jslanguage/expressions/class/gen-method-param-dflt-yield.jslanguage/statements/async-function/early-errors-declaration-await-in-formals.js |
accept/declaration-without-initializer: const / using without an initializer |
9 | 9 | early error: a checker over the tree, not the grammar: not built | language/statements/await-using/syntax/block-scope-syntax-await-using-declarations-mixed-with-without-initializer.jslanguage/statements/const/syntax/block-scope-syntax-const-declarations-mixed-with-without-initialiser.jslanguage/statements/using/syntax/block-scope-syntax-using-declarations-mixed-with-without-initializer.js |
accept/let-as-lexical-name: let as a lexically bound name |
9 | 9 | early error: a checker over the tree, not the grammar: not built | language/statements/const/syntax/const-declaring-let-split-across-two-lines.jslanguage/statements/for-of/head-await-using-bound-names-let.jslanguage/statements/for-of/head-using-bound-names-let.js |
accept/optional-chain-template: a template after an optional chain |
8 | 8 | early error: a checker over the tree, not the grammar: not built | language/expressions/optional-chaining/early-errors-tail-position-null-op-template-string-esi.jslanguage/expressions/optional-chaining/early-errors-tail-position-null-optchain-template-string-esi.jslanguage/expressions/optional-chaining/early-errors-tail-position-op-template-string.js |
accept/using-placement: a using declaration directly in a switch clause |
4 | 4 | early error: a checker over the tree, not the grammar: not built | language/statements/await-using/syntax/await-using-invalid-switchstatement-caseclause.jslanguage/statements/await-using/syntax/await-using-invalid-switchstatement-defaultclause.jslanguage/statements/using/syntax/using-invalid-switchstatement-caseclause.js |
accept/static-block-contexts: arguments, await and yield in a class static block |
3 | 3 | early error: a checker over the tree, not the grammar: not built | language/statements/class/static-init-invalid-arguments.jslanguage/statements/class/static-init-invalid-await.jslanguage/statements/class/static-init-invalid-yield.js |
accept/template-escape: a NotEscapeSequence in an untagged template |
3 | 3 | early error: a checker over the tree, not the grammar: not built | language/expressions/template-literal/invalid-legacy-octal-escape-sequence-8.jslanguage/expressions/template-literal/invalid-legacy-octal-escape-sequence-9.jslanguage/expressions/template-literal/invalid-legacy-octal-escape-sequence.js |
accept/cover-initialized-name: a CoverInitializedName in an object literal |
1 | 1 | early error: a checker over the tree, not the grammar: not built | language/expressions/object/cover-initialized-name.js |
| verdict | files |
|---|---|
| grammar bug: fix | 511 |
| needs a parameterised production the engine lacks (roadmap item 4) | 442 |
| early error: a checker over the tree, not the grammar: not built | 1935 |
accept/rest-element-shape—function f(...a = 1) {},function f(...a,) {},var [...a, b] = c,({...a,} = b)in binding position: FunctionRestParameter and BindingRestElement are... BindingIdentifier | ... BindingPattern, last, with no Initializer and no comma after.accept/await-yield-identifier-reference— IdentifierReference and LabelIdentifier are[~Yield] yield/[~Await] await, parameterised productions the engine has ([Await]/[Yield] families):({await})in an async function,({yield})in a generator,yield: ;in a generator,awaitin a class static block.accept/import-export-not-top-level—{ import v from "m"; },function* g() { export default null; }: ImportDeclaration and ExportDeclaration are ModuleItems, at a module's top level only, in no goal anywhere else. The grammar puts them in Decl, which every block reaches.accept/for-in-of-initializer—for (let x = 1 of y),for (var [a] = 1 of y),for (let x = 1 in o),for (x = 1 in o): ForInOfStatement has no initializer; Annex B (B.3.5) adds only the sloppyfor (var BindingIdentifier Initializer in Expression).accept/using-binding-pattern—using x = 1, [a] = b: ausingLexicalBinding is a BindingIdentifier (BindingList[~Pattern]); only a leadingusing [is an expression (element access).accept/declaration-in-statement-position—while (x) function f() {},if (x) class C {},for (;;) const y = 1,label: async function f() {}: the body of if / while / for / with / a label is a Statement, and Statement has no Declaration (Annex B adds only the sloppyif (x) function f() {}andlabel: function f() {}). The grammar puts Decl in Stmt.accept/restricted-production-line-break—throw⏎1,x⏎=> 1,async x⏎=> 1: the restricted productions forbid the line break, and no ASI applies.accept/coalesce-mixed-with-logical—0 && 0 ?? true,a ?? b || c: CoalesceExpression's operands are BitwiseORExpressions, so neither side may be a bare&&/||.accept/accessor-parameters—get x(a) {}: a getter's parameter list is( ); a setter has exactly one PropertySetParameterList.accept/numeric-literal-lexical—1._5,1._e1: the literal is the longest one (1.), and an IdentifierStart may not follow it; the token backs up to1and lexes._5as a member. Refusing the back-up makes these lex errors, after which the portable lexers' relex of an edit before the error keeps it (x = 1._x;with.inserted: edited rejects, fresh accepts): owed to the lexer lane.accept/switch-statement-outside-clause—switch (x) { a = 2; case 0: }: a CaseBlock holds CaseClauses and a DefaultClause only; the grammar's SwitchCase rule has a bare Stmt arm.accept/strict-mode— Valid in sloppy mode, an error in strict code (reserved wordslet/static/implements/yield…,with, legacy octal literals and escapes,delete x,eval/argumentsas targets or bindings, duplicate parameters, Annex B'sif (x) function f() {}; class bodies are strict). Without a strict mode switch the grammar accepts the sloppy reading.accept/module-goal— Valid in a script, an error in module code:awaitas an identifier, module code is strict, top-levelnew.target/super, import / export /import.metain a Script. Without the script / module goal the grammar accepts the script reading.accept/return-outside-function— ReturnStatement is a Statement[+Return] only: script top level and class static blocks are [~Return]. The engine has no [Return] parameter.accept/private-names— Early error: a#namedeclared twice, used without a declaration in an enclosing class,#constructor,delete this.#x.accept/assignment-target— Early error: AssignmentTargetType is not simple (1 = 2,a?.b = 1,f() += 1,++this), or an ObjectLiteral / ArrayLiteral on the left of=/ in a for-in/of head does not refine to an AssignmentPattern ([...a, b] = c,({a: 1} = b)). The parser enforces the LeftHandSideExpression shape only (docs/CORRECTNESS.md).accept/escaped-keyword— Early error: an IdentifierName whose escapes spell a reserved word is neither that keyword nor an identifier (v\u0061r x,\u0061sync function f() {},yi\u0065ldin a generator).accept/duplicate-bindings— Early error: LexicallyDeclaredNames with a duplicate, or one that also occurs in VarDeclaredNames (let a; var a,let a; let a, acatch (e)withlet ein its block, duplicate parameters where they are not allowed).accept/regexp-pattern— Early error: the body must parse with the Pattern grammar (named groups, quantifiers, class escapes,u/vrules) and the flags must be known and unique. The token reads any body and flag run.accept/super-new-target— Early error: SuperCall outside a derived constructor, SuperProperty outside a method,new.targetoutside a function.accept/use-strict-with-non-simple-parameters— Early error: ContainsUseStrict of the body is true and IsSimpleParameterList is false.accept/await-yield-binding-identifier— Early error: BindingIdentifier derivesyieldandawait, and "It is a Syntax Error if this production has a [Yield] / [Await] parameter". The grammar keeps them names at binding position, as tsc's parser does.accept/arguments-in-class-field— Early error: ContainsArguments of a field's Initializer.accept/labels-break-continue— Early error: an undefined or duplicate label,continueoutside an iteration,breakoutside a breakable statement, IsLabelledFunction.accept/class-element-names— Early error: a special method (getter, setter, generator, async) or field namedconstructor, a static element namedprototype, two constructors.accept/await-yield-in-parameters— Early error: FormalParameters Contains YieldExpression / AwaitExpression.accept/declaration-without-initializer— Early error: a LexicalBinding without an Initializer when IsConstantDeclaration (const x;) or IsUsingDeclaration (using x;).accept/let-as-lexical-name— Early error: BoundNames of a LexicalDeclaration or ForDeclaration contains "let" (const let = 1,for (let let in o)).accept/optional-chain-template— Early error:OptionalChain :: ?. TemplateLiteralandOptionalChain TemplateLiteralare productions with "It is a Syntax Error if any source text is matched by this production" (a?.bx``).accept/using-placement— Early error: a CaseClause / DefaultClause StatementList may not contain a UsingDeclaration or AwaitUsingDeclaration.accept/static-block-contexts— Early error: ContainsArguments / ContainsAwait of ClassStaticBlockStatementList, andyield/awaitreserved there by the block's own [~Yield, +Await] context.accept/template-escape— Early error: "It is a Syntax Error if the [Tagged] parameter was not set and NotEscapeSequence is matched" (\9,\u{,\x0).accept/cover-initialized-name— Early error:({ a = 1 })is matched by the cover grammar for({ a = 1 } = b)and is an error unless it refines to an AssignmentPattern.
TypeScript is a superset of JavaScript, so every test that must parse must parse with typescript.ts too,
unless TypeScript rejects that syntax by design: then tsc's own parser, on the file as a .ts file, rejects it as
well, and its diagnostic is the evidence. A file javascript.ts also rejects is referenced by its JavaScript
class, not classed again. A rejection tsc does not share and the JavaScript grammar does not either would be a
TypeScript grammar bug with no class yet (ts/unknown), and fails the gate. The negative tests are not asked of
the TypeScript grammar; there it is held to tsc's parser (CORRECTNESS.md).
20186 of 20200 valid tests parse (99.9%) · by design 10 · as in JavaScript 4 · unclassified 0 · crash 0
| cell | cause | files | witness | evidence |
|---|---|---|---|---|
ts/by-design |
TypeScript rejects it (JavaScript class reject/annexb-html-comments) |
7 | annexB/language/comments/multi-line-html-close.js |
tsc TS1109: Expression expected. |
ts/by-design |
TypeScript rejects it (JavaScript class javascript.ts parses it) |
1 | language/literals/numeric/legacy-octal-integer.js |
tsc TS1121: Octal literals are not allowed. Use the syntax '0o0'. |
ts/by-design |
TypeScript rejects it (JavaScript class javascript.ts parses it) |
1 | language/literals/numeric/non-octal-decimal-integer.js |
tsc TS1489: Decimals with leading zeros are not allowed. |
ts/by-design |
TypeScript rejects it (JavaScript class reject/annexb-html-comments) |
1 | annexB/language/comments/single-line-html-open.js |
tsc TS1110: Type expected. |
ts/as-javascript |
the JavaScript class reject/lexer-division-after-object-literal |
2 | language/expressions/division/bigint-toprimitive.js |
tsc's .ts parser accepts it |
ts/as-javascript |
the JavaScript class reject/lexer-optional-chain-before-digit |
1 | language/expressions/optional-chaining/punctuator-decimal-lookahead.js |
tsc's .ts parser accepts it |
ts/as-javascript |
the JavaScript class reject/optional-chain-bracket-comma-expression |
1 | language/expressions/optional-chaining/optional-chain-prod-expression.js |
tsc's .ts parser accepts it |
The static-semantic rules ("It is a Syntax Error if …") stay out of the context-free grammar, but not out of the project: acorn enforces all but a handful of them (the calibration below), so a JavaScript front end is expected to. They belong to a pass over the parsed tree, which does not exist yet. This table is its specification, ranked by the files each rule decides: tree means the node and its ancestors suffice; scope means the pass must collect the names each scope (or class) declares.
| class | files | needs | what the checker reads |
|---|---|---|---|
accept/private-names: private names |
346 | scope | the private names each class declares, resolved through the enclosing classes (duplicates, getter / setter pairing, undeclared uses), plus delete of a private reference |
accept/assignment-target: an invalid assignment target, or a literal that does not cover an AssignmentPattern |
319 | tree | the left side of an assignment, an update or a for-in/of head: AssignmentTargetType, and the refinement of a literal to an AssignmentPattern |
accept/escaped-keyword: a keyword written with a Unicode escape |
304 | tree | an identifier token: its escape-decoded text against the reserved words, with the enclosing function kind for await / yield |
accept/duplicate-bindings: duplicate or conflicting declarations |
248 | scope | the declared names of every block, function, switch and module scope: LexicallyDeclaredNames against themselves and against VarDeclaredNames, and parameter names |
accept/regexp-pattern: a regular expression's pattern or flags |
170 | tree | a regular-expression token: its body against the Pattern grammar, its flags against the flag set |
accept/super-new-target: super and new.target outside their contexts |
154 | tree | a super / new.target node and its enclosing function and method kinds |
accept/use-strict-with-non-simple-parameters: "use strict" in a function with a non-simple parameter list |
110 | tree | a function node: its parameter list's shape and its body's directive prologue |
accept/await-yield-binding-identifier: await / yield as a binding name in an async function / generator |
72 | tree | a binding name and its enclosing function kinds (async, generator, static block) |
accept/arguments-in-class-field: arguments in a class field initializer |
58 | tree | a field initializer: does it contain arguments outside a non-arrow function |
accept/labels-break-continue: labels, break and continue |
53 | tree | a statement and its enclosing labels and iteration / breakable statements, stopping at function and static-block boundaries |
accept/class-element-names: class elements named constructor / prototype |
44 | tree | a class body: element names and kinds (constructor, prototype, a second constructor) |
accept/await-yield-in-parameters: an await / yield expression in formal parameters |
20 | tree | a parameter list: does it contain a YieldExpression / AwaitExpression outside a nested function |
accept/declaration-without-initializer: const / using without an initializer |
9 | tree | a const / using binding: does it have an initializer (outside a for-in/of head) |
accept/let-as-lexical-name: let as a lexically bound name |
9 | tree | a lexical declaration's bound names: is one of them let |
accept/optional-chain-template: a template after an optional chain |
8 | tree | an optional chain: is a template literal applied to it |
accept/using-placement: a using declaration directly in a switch clause |
4 | tree | a using declaration and its parent: a case / default clause directly |
accept/static-block-contexts: arguments, await and yield in a class static block |
3 | tree | a class static block: does it contain arguments or an AwaitExpression outside a nested function |
accept/template-escape: a NotEscapeSequence in an untagged template |
3 | tree | an untagged template token: does it contain a NotEscapeSequence |
accept/cover-initialized-name: a CoverInitializedName in an object literal |
1 | tree | an object literal not refined to an AssignmentPattern: does it contain a CoverInitializedName |
Tree alone: 1341 files; scope analysis: 594 files. The strict-mode and Module-goal rules (needs-parameter above) are early errors too where they forbid a name or a statement; they are counted there because they need the goal and mode first.
How many test262 parse verdicts each parser gets right (read-only; no gate rides on these columns beyond
the record being current). acorn: ecmaVersion: 'latest', sourceType per the test, strict runs with
"use strict"; prepended, right only if right in every run. tsc: ts.createSourceFile as a .js file (a
module test forced to module detection), right only if no parse diagnostic exactly where test262 expects
none; "+ binder" also counts the binder's diagnostics (bindSourceFile: strict-mode words, duplicate
declarations, labels, which tsc reports outside its parser; it includes TypeScript's own checks).
| parser | right | of 24677 | on the 20200 valid tests | on the 4477 parse-negative tests |
|---|---|---|---|---|
javascript.ts (interpreter) |
21777 | 88.2% | 20188 (99.9%) | 1589 (35.5%) |
| acorn 8.16.0 | 24394 | 98.9% | 19926 (98.6%) | 4468 (99.8%) |
| tsc 5.9.3 parser | 21391 | 86.7% | 20123 (99.6%) | 1268 (28.3%) |
| tsc 5.9.3 parser + binder | 21829 | 88.5% | 19934 (98.7%) | 1895 (42.3%) |
Of the 2888 WE-ACCEPT files, acorn also accepts 0 (in every run), tsc's parser 2528, tsc's parser + binder 1901.