-
Notifications
You must be signed in to change notification settings - Fork 184
-
Notifications
You must be signed in to change notification settings - Fork 184
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
RubyLanguage.findLocalScopes(node, null) provides all local variables in the scope ignoring node's position #1335
Comments
see |
Hello, thank you for the report. I am not sure what you mean. In Ruby, all local variables are defined from the start of the function, so for instance: def halloHallo(x)
a = 1
p binding.eval("b") # reads local var b
b = 2
end
halloHallo(3) prints Note that in SL, if the implementation of We should probably override |
Oh, I was not aware of this. Yes I was expecting
In SL, they traverse the AST until they reach the
So in SL you get |
Could you point to the code doing that? I didn't see it from a quick look at SL's |
I found it, the logic is in https://github.com/oracle/graal/blob/9fa5e821d944ee9e0c8f9422e713903b66e4d15d/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLLexicalScope.java#L253. @chrisseaton @chumer Should we implement a similar logic in TruffleRuby to only return variables which have been assigned for |
We have an issue to implement I've got another opinion on when local variable are 'defined' logically though: def halloHallo(x)
a = 1
p defined?(a) # "local-variable"
p defined?(b) # nil
b = 2
end
halloHallo(3) So I think maybe we should only return them when Ruby considers them to be |
Being tracked internally as GR-4055. |
|
findLocalScopes(node, null)
returns always[x, a, b]
for anode
insidehalloHallo(x)
. I think this is the default implementation returning all frame slots, ifframe
parameter infindLocalScopes(node, frame)
isnull
.Is it possible to implement it for RubyLanguage (or Truffle in general?) the way SL is doing it (see SLLanguage.findLocalScopes() how it should be done by collecting only the local variables already defined).
I would appreciate this to do language agnostic static code analysis for Truffle languages.
The text was updated successfully, but these errors were encountered: