Skip to content

Fix JuliaSyntax error handling for invalid dotted operators#60843

Open
riazation42 wants to merge 3 commits intoJuliaLang:masterfrom
riazation42:fix-dotted-operator-error-handling
Open

Fix JuliaSyntax error handling for invalid dotted operators#60843
riazation42 wants to merge 3 commits intoJuliaLang:masterfrom
riazation42:fix-dotted-operator-error-handling

Conversation

@riazation42
Copy link
Contributor

Fixes #60665

Problem

When parsing invalid dotted operators like a .:= b, JuliaSyntax was calling error() which ignored the raise=false flag and caused crashes in contexts like REPL history search.

Solution

  • Modified dotted() function to accept ps::ParseState parameter
  • Replaced error() with emit_diagnostic() for error handling
  • Returns K"error" marker instead of throwing exception
  • Updated call sites in parse_lazy_cond() and parse_assignment_with_initial_ex() to pass ParseState

Testing

Added test cases verifying invalid dotted operators return error expressions instead of crashing when raise=false is specified.

Test Results

meta parse
  • Meta.parse("a .:= b"; raise=false) returns error expression (doesn't crash)
  • ✅ Valid dotted operators like .= continue to work
  • ✅ With raise=true, properly throws ParseError

Note AI tools were used to learn parser internals and error handling; all code was written and tested by me.

When parsing invalid dotted operators like 'a .:= b', JuliaSyntax
was calling error() which ignored the raise=false flag and caused
crashes in contexts like REPL history search.

Changed dotted() function to accept ps::ParseState parameter and
use emit_diagnostic() instead of error() for graceful error handling.

Updated all call sites to pass ParseState parameter and added tests.

Fixes JuliaLang#60665
Copy link
Member

@Keno Keno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes seems good in general, but specific comments above.

Co-authored-by: Keno Fischer <[email protected]>
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.

Meta.parse("a .:= b"; raise=false) produces an error log from JuliaSyntax in 1.13

3 participants