Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meta.parse consumes inconsistent amount of input in non-greedy mode #32958

Closed
c42f opened this issue Aug 19, 2019 · 1 comment
Closed

Meta.parse consumes inconsistent amount of input in non-greedy mode #32958

c42f opened this issue Aug 19, 2019 · 1 comment
Labels
bug Indicates an unexpected problem or unintended behavior parser Language parsing and surface syntax

Comments

@c42f
Copy link
Member

c42f commented Aug 19, 2019

Meta.parse in non-greedy mode uses the character stream position (via io.pos in jl-parse-one), but the parser may already have read the next token using peek-token. This can cause the returned position to be inconsistent. For example:

julia> Meta.parse("x,", 1, greedy=false)
(:x, 2)

julia> Meta.parse(":,", 1, greedy=false)
(:(:), 3)  # should this be (:(:), 2) ?

I found this problem while chasing down a bug in Base.shell_parse caused by #32408.

@c42f c42f added parser Language parsing and surface syntax bug Indicates an unexpected problem or unintended behavior labels Aug 19, 2019
@Moelf
Copy link
Contributor

Moelf commented Oct 30, 2023

this is now fixed:

  | | |_| | | | (_| |  |  Version 1.11.0-DEV.747 (2023-10-26)
 _/ |\__'_|_|_|\__'_|  |  Commit 837522aadd (4 days old master)
|__/                   |

julia> Meta.parse("x,", 1, greedy=false)
(:x, 2)

julia> Meta.parse(":,", 1, greedy=false)
(:(:), 2)

@vtjnash vtjnash closed this as completed Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior parser Language parsing and surface syntax
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants