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

Beginless ranges and line breaks #814

Closed
mvz opened this issue Aug 1, 2021 · 1 comment · Fixed by #822
Closed

Beginless ranges and line breaks #814

mvz opened this issue Aug 1, 2021 · 1 comment · Fixed by #822

Comments

@mvz
Copy link
Contributor

mvz commented Aug 1, 2021

This code seems to be parsed incorrectly:

def bar
  foo = 2
  ..foo
end

Calling bar returns ..2, but Parser parser this as:

s(:def, :bar,
  s(:args),
  s(:lvasgn, :foo,
    s(:irange,
      s(:int, 2),
      s(:lvar, :foo))))

I would expect this to be parser identically to

def bar
  foo = 2;
  ..foo
end

This version is parsed by Parser as:

s(:def, :bar,
  s(:args),
  s(:begin,
    s(:lvasgn, :foo,
      s(:int, 2)),
    s(:irange, nil,
      s(:lvar, :foo))))
@iliabylich
Copy link
Collaborator

Yes, looks like a bug, tDOT2 is emitted instead of tBDOT2 and it's reduced to a normal range

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 a pull request may close this issue.

2 participants