Skip to content

feat: semantic error recovery — interpret statements that pass semantic checking #113

Description

@dvhthomas

Summary

When a block has semantic errors (like variable redefinition), the evaluator aborts before interpretation. Statements that passed semantic checking never run, so runtime errors (like 1 / 0) and successful computations are invisible.

Example

a = 1 / 0    ← no diagnostic shown (interpretation never ran)
a = 2        ← ✗ cannot reassign 'a'
c = 3        ← no value shown
c = 5        ← ✗ cannot reassign 'c'

Expected: a = 1 / 0 should show ✗ division by zero and c = 3 should show = 3.

Current Behavior

The semantic checker collects all error diagnostics (fixed in #112). But the evaluator returns immediately after semantic errors without interpreting any statements. Statements that are semantically valid (like a = 1 / 0 and c = 3) never execute.

Proposed Approach

After collecting semantic diagnostics, still run interpretation for statements that passed semantic checking. Skip statements that have semantic errors. This would require:

  1. Marking which AST nodes have semantic errors (by line number from diagnostics)
  2. Running the interpreter on non-errored nodes only
  3. Collecting both semantic and runtime diagnostics on the same block

Context

Discovered during #73 / #112 error recovery work. The evaluator now recovers from runtime errors (statement-level and block-level), but semantic errors still abort the block entirely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions