Skip to content

Improve error recovery in collections#21

Merged
dereuromark merged 2 commits into
masterfrom
improve-error-recovery
Mar 30, 2026
Merged

Improve error recovery in collections#21
dereuromark merged 2 commits into
masterfrom
improve-error-recovery

Conversation

@dereuromark
Copy link
Copy Markdown
Contributor

@dereuromark dereuromark commented Mar 30, 2026

Summary

Implements improved error recovery

  • Add context-aware error recovery that prevents cascading errors when parsing malformed arrays and inline tables
  • Add bracket stack tracking to monitor nesting context
  • Implement synchronizeInCollection() that recovers to next comma or closing bracket instead of skipping to newline
  • Update parseArray() and parseInlineTable() to use bracket-aware recovery

Before vs After

data = [{a = 1}, {b = }, {c = 3}]
other = "value"

Before: 4 cascading errors

Line 1:22: Expected value
Line 2:0: Expected }
Line 2:0: Expected ]
Line 2:0: Expected newline or end of input after value

After: 1 precise error

Line 1:22: Expected value

This enables better IDE/tooling support by providing more accurate error locations and preserving more of the document structure.

Add context-aware error recovery that prevents cascading errors when
parsing malformed arrays and inline tables.

Changes:
- Add bracket stack tracking to monitor nesting context
- Implement synchronizeInCollection() that recovers to next comma or
  closing bracket instead of skipping to newline
- Add parseInlineTableKeyValue() and parseKeyWithoutSync() to avoid
  line-based synchronization inside inline tables
- Update parseArray() and parseInlineTable() to use bracket-aware recovery

Before: `{a = 1, b = , c = 3}` would generate 3-5 cascading errors
After: Same input generates 1 precise error at the correct location

This enables better IDE/tooling support by providing more accurate
error locations and preserving more of the document structure.
@dereuromark dereuromark merged commit 305fc5a into master Mar 30, 2026
3 checks passed
@dereuromark dereuromark deleted the improve-error-recovery branch March 30, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant