Make TGocciaLexerError inherit from TGocciaSyntaxError#627
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughTGocciaLexerError now inherits from TGocciaSyntaxError. Exception-to-error mapping and matcher logic were narrowed to rely on the parent type; unit and CLI tests were added/updated; documentation and example catch ordering were revised to reflect the new hierarchy. ChangesError Hierarchy Restructuring
Sequence Diagram(s)sequenceDiagram
participant Client
participant Loader
participant Lexer
participant VM
Client->>Loader: request load (invalid input)
Loader->>Lexer: tokenize/parse
Lexer-->>Loader: raises TGocciaLexerError
Loader->>VM: propagate exception during OP_USING_DISPOSE
VM->>VM: check E is TGocciaSyntaxError?
alt yes
VM-->>Client: CreateErrorObject(SYNTAX_ERROR_NAME) -> JSON { error.type: "SyntaxError" }
else no
VM-->>Client: CreateErrorObject(ERROR_NAME) -> JSON { error.type: "Error" }
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
The ES spec treats all early errors (lexer and parser) as SyntaxError. Reparenting TGocciaLexerError under TGocciaSyntaxError aligns the internal hierarchy with the spec and eliminates the compensating `or (E is TGocciaLexerError)` checks added in #619. Closes #626 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Suite TimingTest Runner (interpreted: 9,243 passed; bytecode: 9,243 passed)
MemoryGC rows aggregate the main thread plus all worker thread-local GCs. Test runner worker shutdown frees thread-local heaps in bulk; that shutdown reclamation is not counted as GC collections or collected objects.
Benchmarks (interpreted: 407; bytecode: 407)
MemoryGC rows aggregate the main thread plus all worker thread-local GCs. Benchmark runner performs explicit between-file collections, so collection and collected-object counts can be much higher than the test runner.
Measured on ubuntu-latest x64. |
Benchmark Results407 benchmarks Interpreted: 🟢 350 improved · 🔴 27 regressed · 30 unchanged · avg +10.3% arraybuffer.js — Interp: 🟢 12, 2 unch. · avg +11.4% · Bytecode: 🟢 7, 🔴 2, 5 unch. · avg +5.0%
arrays.js — Interp: 🟢 18, 1 unch. · avg +14.1% · Bytecode: 🟢 5, 🔴 9, 5 unch. · avg -0.4%
async-await.js — Interp: 🟢 5, 1 unch. · avg +11.7% · Bytecode: 🟢 5, 1 unch. · avg +6.1%
async-generators.js — Interp: 🟢 1, 1 unch. · avg +12.8% · Bytecode: 2 unch. · avg +9.1%
base64.js — Interp: 🟢 3, 🔴 7 · avg +1.2% · Bytecode: 🟢 3, 🔴 3, 4 unch. · avg +1.3%
classes.js — Interp: 🟢 27, 4 unch. · avg +9.1% · Bytecode: 🟢 6, 🔴 5, 20 unch. · avg -0.3%
closures.js — Interp: 🟢 11 · avg +12.8% · Bytecode: 11 unch. · avg -0.2%
collections.js — Interp: 🟢 11, 1 unch. · avg +11.6% · Bytecode: 🟢 9, 3 unch. · avg +8.4%
csv.js — Interp: 🟢 13 · avg +12.9% · Bytecode: 🔴 11, 2 unch. · avg -4.4%
destructuring.js — Interp: 🟢 21, 1 unch. · avg +10.4% · Bytecode: 🟢 5, 17 unch. · avg +2.2%
fibonacci.js — Interp: 🟢 8 · avg +14.0% · Bytecode: 🟢 7, 1 unch. · avg +5.4%
float16array.js — Interp: 🟢 26, 🔴 2, 4 unch. · avg +6.9% · Bytecode: 🟢 16, 🔴 8, 8 unch. · avg +3.9%
for-of.js — Interp: 🟢 7 · avg +10.7% · Bytecode: 🔴 5, 2 unch. · avg -3.2%
generators.js — Interp: 🟢 4 · avg +9.9% · Bytecode: 🟢 4 · avg +7.1%
iterators.js — Interp: 🟢 41, 1 unch. · avg +10.2% · Bytecode: 🟢 13, 🔴 8, 21 unch. · avg +0.7%
json.js — Interp: 🟢 19, 1 unch. · avg +11.9% · Bytecode: 🟢 5, 🔴 2, 13 unch. · avg +0.5%
jsx.jsx — Interp: 🟢 21 · avg +12.7% · Bytecode: 🟢 3, 🔴 5, 13 unch. · avg +0.2%
modules.js — Interp: 🟢 5, 4 unch. · avg +7.5% · Bytecode: 🔴 1, 8 unch. · avg -2.0%
numbers.js — Interp: 🟢 11 · avg +11.2% · Bytecode: 🟢 5, 6 unch. · avg +2.9%
objects.js — Interp: 🟢 7 · avg +9.8% · Bytecode: 🔴 6, 1 unch. · avg -6.2%
promises.js — Interp: 🟢 11, 1 unch. · avg +8.5% · Bytecode: 🟢 3, 9 unch. · avg +0.9%
regexp.js — Interp: 🟢 5, 🔴 6 · avg -1.1% · Bytecode: 🟢 1, 🔴 1, 9 unch. · avg -0.1%
strings.js — Interp: 🟢 19 · avg +19.2% · Bytecode: 🟢 2, 🔴 7, 10 unch. · avg -1.2%
tsv.js — Interp: 🟢 8, 1 unch. · avg +9.9% · Bytecode: 🔴 5, 4 unch. · avg -3.3%
typed-arrays.js — Interp: 🟢 15, 🔴 2, 5 unch. · avg +6.5% · Bytecode: 🟢 12, 🔴 4, 6 unch. · avg +21.4%
uint8array-encoding.js — Interp: 🟢 17, 1 unch. · avg +36.9% · Bytecode: 🟢 3, 🔴 10, 5 unch. · avg +0.2%
weak-collections.js — Interp: 🟢 4, 🔴 10, 1 unch. · avg -19.0% · Bytecode: 🔴 6, 9 unch. · avg -15.0%
Deterministic profile diffDeterministic profile diff: no significant changes. Measured on ubuntu-latest x64. Benchmark ranges compare cached main-branch min/max ops/sec with the PR run; overlapping ranges are treated as unchanged noise. Percentage deltas are secondary context. |
test262 Conformance
Areas closest to 100%
Per-test deltas (+4 / -0)Newly passing (4):
Steady-state failures are non-blocking; regressions vs the cached main baseline (lower total pass count, or any PASS → non-PASS transition) fail the conformance gate. Measured on ubuntu-latest x64, bytecode mode. Areas grouped by the first two test262 path components; minimum 25 attempted tests, areas already at 100% excluded. Δ vs main compares against the most recent cached |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/value-system.md`:
- Line 752: Revise the sentence so it distinguishes early (parser/lexer) errors
from runtime errors: state that TGocciaError is a Pascal Exception superclass
(not a TGocciaValue and not a JavaScript Error), that TGocciaSyntaxError and
TGocciaLexerError represent early parser/lexer errors (mirroring ES
SyntaxError), and separately state that TGocciaRuntimeError represents runtime
engine errors; keep the note that these are internal Pascal exceptions and not
JS error objects and mirror the ES spec's subclassing where appropriate.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: efb72ff0-8005-4f1e-baaf-bb7fb6dc98c8
📒 Files selected for processing (10)
docs/embedding.mddocs/errors.mddocs/interpreter.mddocs/value-system.mdscripts/test-cli-lexer.tssource/units/Goccia.Builtins.TestingLibrary.passource/units/Goccia.Error.Test.passource/units/Goccia.Error.passource/units/Goccia.Evaluator.passource/units/Goccia.VM.pas
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Persist for-loop iteration state across generator resumes (#538) The interpreter's EvaluateFor had no resume state, so a yield inside the init, test, body, or update of a traditional for(;;) loop caused every subsequent g.next() to re-enter the function from the top: Init re-ran, HeaderScope/IterScope were re-created, and the loop counter never advanced. The bytecode VM already preserved equivalent state in its frame machinery; this brings the interpreter to parity. Adds TGocciaGeneratorForLoopState (Phase + HeaderScope + IterScope) keyed by the for statement AST node, mirroring the existing TGocciaGeneratorLoopState used for for-of. On resume EvaluateFor restores the saved scopes and jumps to gflpIterStart / gflpBody / gflpUpdate. Sub-expression-level partial resume continues to use the existing EvaluateExpression save/take cache, so a yield mid-condition or mid-update round-trips correctly. Closes #538 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * Move for-loop generator yield tests into existing for-loop dirs Tests previously lived in tests/language/for-loop-generator/ which needed a separate goccia.json with compat-function so function* declarations could be parsed. Rewrite each test to use object-method generators ({ *gen() {} }), which need no compat-function flag, and fold them into the existing for-loop/ directory (and for-loop-var/ for the new var-init yield test) so they ride the parent goccia.json. Adds generator-yield.js under for-loop-var/ covering yield with var init, init-runs-once across resumes, post-loop var visibility, and update-yield with var. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * Drop decision-log entry for #538 A bug fix that brings the interpreter into spec compliance (and into parity with the bytecode VM) doesn't warrant a decision-log entry — that's reserved for architectural and implementation decisions. The commit history and PR description already document the change. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * Remove unrelated TGocciaLexerError check that leaked into the diff PascalExceptionToErrorObject had an `or (E is TGocciaLexerError)` clause that was not part of #538 and is redundant after #627 made TGocciaLexerError inherit from TGocciaSyntaxError. Revert to match main.
Summary
TGocciaLexerErrorfromTGocciaErrortoTGocciaSyntaxError, aligning the internal exception hierarchy with the ES spec which treats all early errors (lexer and parser) uniformly asSyntaxError.or (E is TGocciaLexerError)clauses added in String literals should reject unescaped line terminators per ES spec #619 (evaluator, VM, testing library) — now redundant sinceE is TGocciaSyntaxErrorcovers lexer errors via inheritance.TGocciaLexerErrorbranch inErrorDisplayName.SyntaxErrorat the language level.Closes #626
Testing