You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two more structure bugs from the widened oracle; valid-only contract
Bug #2 - statement-position function merged with a following call: longest-
match let the expression arm win whenever a member/call tail made it LONGER
("function f(){}" + newline + "(g)()" became ONE IIFE-style expression
statement; tsc keeps a declaration + a separate statement). Fix: the ES2023
14.5 ExpressionStatement lookahead restriction - the expression arm may not
begin with function / async function. "class" is deliberately NOT guarded yet:
the class-DECLARATION arm is narrower than tsc's (extends-expression heritage,
bare ';' class elements, decorator placements), so 31 tsc-valid corpus files
still rely on the class-EXPRESSION fallback - widening the declaration arm is
the named prerequisite. The guard flips exactly 3 corpus files to reject, all
tsc-INVALID (template-typed params, "function* gen" without parens): FN=0
held. Rest parameters also gained their checker-not-parser tail
("...b = init", "...b?: T") so the declaration arm carries what the expression
fallback used to.
Bug #3 (pre-existing, all builds) - bare for-in heads: ForHead's
no-declaration arm parsed its target Expr WITHOUT the no-"in" exclusion, so
"for (key in obj)" swallowed the "in" inside an in-LED, the arm failed, and
the statement fell back to a CALL parse "for(...)" with "for" as an
identifier. Same exclude as binding initializers on the target.
The interpreter's maxPos moves to advance-based tracking (mirroring the
emitted engine's relocation) - the new reject inputs exposed that the two
engines' farthest-position semantics had silently diverged; reject messages
are engine-identical again (468 files).
ts-ast-verify gains the valid-only contract: files where tsc itself reports
parse errors are SKIPPED (error-recovery shapes are each parser's own policy,
not the grammar contract) - parserharness/parserRealSource7 fall under it; the
lowering still gained their missing shapes (NewTarget index form, old-style
type assertion). Gate corpus widened to fixSignatureCaching (2,952 nodes) +
parserindenter (3,168), both node-identical to tsc. 28/28 gates; 18,805-file
interp=emit; conformance 5383/5659 (baseline minus the 3 correct rejects).
letmaxPos=0;// farthest token index the parser ever attempted to read (diagnostic)
763
+
letmaxPos=0;// farthest token index ever ADVANCED past (diagnostic; updated at the pos++ sites, mirroring the emitted engine so reject messages stay engine-identical)
764
764
// Packrat memo for pratt/left-recursive rules (Expr, Type, …): cache the
765
765
// parse result + end position by start position, so backtracking doesn't
766
766
// re-parse the same rule at the same spot. Sound because those rules reset
@@ -777,7 +777,6 @@ export function createParser(grammar: CstGrammar) {
777
777
letparseLimit=-1;
778
778
779
779
functionpeek(): Token|null{
780
-
if(pos>maxPos)maxPos=pos;
781
780
if(parseLimit>=0&&pos>=parseLimit)returnnull;
782
781
returntokens[pos]??null;
783
782
}
@@ -794,14 +793,14 @@ export function createParser(grammar: CstGrammar) {
794
793
if(isKeywordLiteral(value)){
795
794
// Keyword literal: match against Ident token with same text
['...',alt([notReserved,Ident],BindingPattern),opt('?'),opt(':',Type),opt('=',Expr)],// rest (`?`/initializer are CHECKER errors in tsc, not parse errors)
0 commit comments