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

Parser: fix the condition to decide var or call #5336

Merged

Conversation

makenowjust
Copy link
Contributor

@makenowjust makenowjust commented Dec 1, 2017

There is source code foo, this foo is decided var or call on parsing, and the condition for this has some bugs.

First bug, foo(+1) is parsed as foo + 1 if foo is variable. For example:

foo = 1
p foo(+1) # => 2 (wtf??)

Second bug, case 1 when foo then 2 end is parsed as case 1 when foo() then 2 end even if foo is variable. For example:

foo = 1
case 1
when foo then 2
end

# Error: undefined method 'foo'

These bugs are fixed in this PR. Thank you.

There is source code `foo`, this `foo` is decided var or call on
parsing and the condition for this has a bug.

First, `foo(+1) is parsed as `foo + 1` if `foo` is variable.
Second, `case 1 when foo then 2` is parsed as `case 1 when foo() then 2`
even if `foo` is variable.

These bugs are fixed in this commit.
@ysbaddaden ysbaddaden merged commit 20e0cf9 into crystal-lang:master Dec 4, 2017
@makenowjust makenowjust deleted the fix/crystal/var-or-call-rule branch December 4, 2017 08:01
@RX14 RX14 added this to the Next milestone Dec 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants