Skip to content

Conversation

@c42f
Copy link
Member

@c42f c42f commented Feb 13, 2025

Rework incomplete expression detection so that trailing whitespace is always ignored, regardless of how the parser itself decides to attach it to other nodes of the tree.

To do this, we walk back from the end of the parse stream and look for the byte offset of the last non-whitespace token. We then use that to determine whether the error node is "at the end of the parse".

Improve testing by

  • Extracting the incomplete expressions which are part of the REPL stdlib tests and ensuring these match the incomplete tag generation of the flisp parser. Fix some divergences for var"" syntax and invalid escape sequences in strings.
  • Ensuring that we test both :statement and :all level parsing - the REPL uses :all to allow parsing of multiple top level statements, so we need to test this.

Also fix a minor bug where enable_in_core!(false) would result in the flisp parser being used, regardless of whether VERSION ships with JuliaSyntax enabled by default.

Fixes #519. See also #518.

@c42f c42f force-pushed the caf/incomplete-expression-fixes branch from c567e14 to c9cd5be Compare February 13, 2025 05:00
@codecov
Copy link

codecov bot commented Feb 13, 2025

Codecov Report

Attention: Patch coverage is 81.25000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 96.25%. Comparing base (30109d4) to head (c9cd5be).
Report is 18 commits behind head on main.

Files with missing lines Patch % Lines
src/hooks.jl 77.77% 2 Missing ⚠️
src/parse_stream.jl 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #538      +/-   ##
==========================================
+ Coverage   96.18%   96.25%   +0.07%     
==========================================
  Files          13       13              
  Lines        4032     4329     +297     
==========================================
+ Hits         3878     4167     +289     
- Misses        154      162       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Rework incomplete expression detection so that trailing whitespace is
always ignored, regardless of how the parser itself decides to attach it
to other nodes of the tree.

To do this, we walk back from the end of the parse stream and look for
the byte offset of the last non-whitespace token. We then use that to
determine whether the error node is "at the end of the parse".

Improve testing by
* Extracting the incomplete expressions which are part of the REPL
  stdlib tests and ensuring these match the incomplete tag generation of
  the flisp parser. Fix some divergences for `var""` syntax and invalid
  escape sequences in strings.
* Ensuring that we test both `:statement` and `:all` level parsing - the
  REPL uses `:all` to allow parsing of multiple top level statements, so
  we need to test this.

Also fix a minor bug where `enable_in_core!(false)` would result in the
flisp parser being used, regardless of whether `VERSION` ships with
JuliaSyntax enabled by default.

Fixes #519. See also #518.
@c42f c42f force-pushed the caf/incomplete-expression-fixes branch from c9cd5be to 3a76a1b Compare February 13, 2025 05:10
@fingolfin
Copy link
Member

Thank you!

Is there a chance this will be in Julia 1.12?

@c42f
Copy link
Member Author

c42f commented Feb 13, 2025

Yes, this is a bug fix so it should go into 1.12.

@c42f c42f merged commit e0342c0 into main Feb 13, 2025
36 checks passed
@c42f c42f deleted the caf/incomplete-expression-fixes branch February 13, 2025 11:20
c42f added a commit to JuliaLang/julia that referenced this pull request Oct 17, 2025
…ng/JuliaSyntax.jl#538)

Rework incomplete expression detection so that trailing whitespace is
always ignored, regardless of how the parser itself decides to attach it
to other nodes of the tree.

To do this, we walk back from the end of the parse stream and look for
the byte offset of the last non-whitespace token. We then use that to
determine whether the error node is "at the end of the parse".

Improve testing by
* Extracting the incomplete expressions which are part of the REPL
  stdlib tests and ensuring these match the incomplete tag generation of
  the flisp parser. Fix some divergences for `var""` syntax and invalid
  escape sequences in strings.
* Ensuring that we test both `:statement` and `:all` level parsing - the
  REPL uses `:all` to allow parsing of multiple top level statements, so
  we need to test this.

Also fix a minor bug where `enable_in_core!(false)` would result in the
flisp parser being used, regardless of whether `VERSION` ships with
JuliaSyntax enabled by default.

Fixes JuliaLang/JuliaSyntax.jl#519. See also JuliaLang/JuliaSyntax.jl#518.
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.

ParseError when typing multi-line input with comment

2 participants