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

Shadow arguments not parsed as local variables #269

Closed
akimd opened this issue Nov 7, 2018 · 1 comment
Closed

Shadow arguments not parsed as local variables #269

akimd opened this issue Nov 7, 2018 · 1 comment

Comments

@akimd
Copy link

akimd commented Nov 7, 2018

[1].each do |x; a, b, c|
  puts x + a + b + c
end

gives

s(:iter,
  s(:call, s(:array, s(:lit, 1)), :each),
  s(:args, :x, s(:shadow, :a, :b, :c)),
  s(:call, nil, :puts, s(:call, s(:call, s(:call, s(:lvar, :x), :+, s(:call, nil, :a)), :+, s(:call, nil, :b)), :+, s(:call, nil, :c))))

Note that a, b and c are considered to be attributes, not variables, contrary to x.

@zenspider
Copy link
Member

Fixed:

s(:iter,
 s(:call, s(:array, s(:lit, 1)), :each),
 s(:args, :x, s(:shadow, :a, :b, :c)),
 s(:call,
  nil,
  :puts,
  s(:call,
   s(:call, s(:call, s(:lvar, :x), :+, s(:lvar, :a)), :+, s(:lvar, :b)),
   :+,
   s(:lvar, :c))))

@seattlerb seattlerb locked and limited conversation to collaborators Jan 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants