Skip to content
New issue

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

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

Already on GitHub? # to your account

Incorrect Parse in global statement #339

Closed
Xpectuer opened this issue May 7, 2022 · 1 comment
Closed

Incorrect Parse in global statement #339

Xpectuer opened this issue May 7, 2022 · 1 comment

Comments

@Xpectuer
Copy link

Xpectuer commented May 7, 2022

When global statement is parsed, there is a incorrect behavior.
Here is the example
source:

global a = 1, b

The statement above is parsed into:

(global 
(assign a (tuple 1 b)))

whereas the expected one is:

(global 
(assign a  1) b)

截屏2022-05-07 下午1 44 30

Hope for a fix.

@pfitzseb
Copy link
Member

pfitzseb commented May 11, 2022

What makes you think that this is the expected behaviour? We're matching Meta.parse here:

julia> CSTParser.parse("global a=2, b")
  1:13  global
  1:6      1:1   OP: =
  1:1     a
  2:5     tuple
  2:2      INTEGER: 2
  3:3      b

julia> CSTParser.to_codeobject(CSTParser.parse("global a=2, b"))
:(global a = (2, b))

julia> Meta.parse("global a=2, b")
:(global a = (2, b))

julia> global a = (2,b)
ERROR: UndefVarError: b not defined
Stacktrace:
 [1] top-level scope
   @ REPL[11]:1

julia> b = 2
2

julia> global a = (2,b)
(2, 2)

julia> a
(2, 2)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants