-
-
Notifications
You must be signed in to change notification settings - Fork 925
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: How to know the block-local variables #4181
Comments
@enebo will have to answer with details, but I can say a few things. This isn't really part of the arg list (or the signature of the block) at all. I believe it's handled in the parser by just forcibly declaring that variable name at the current level (depth 0), so it is from then on handled as local to the block. The fact that it was declared such is not directly reflected in any of the final parse artifacts. If it overlaps with an enclosing scope, it will just show up in the StaticScope hierarchy as an overlapping variable declaration. If it doesn't overlap, it may not be possible to tell a variable was declared this way. |
@eregon I don't think it was intentionally removed but it maintains a a field and optionally a whole arraylist per argsnode. Memory is a huge problem for us so I guess if you really need to be able to determine this style of variable (we do not as we depend on StaticScope for this) we could maybe make a specialized ArgsNode so we only pay any extra memory cost when this feature is actually used. |
@enebo I'm not quite following. One could add the variable when noticing a DAsgnNode with depth==0, but that seems a very indirect way too. |
@enebo I ended up using the StaticScope, so feel free to remove |
@enebo @headius
How does the AST carry the list of block-local variables?
Say the following code:
At some point @chrisseaton stored it e6da2d8 in the ArgsNode, but it seems @enebo's merge killed in 8d092c6 that code. Interestingly GitHub seems to hide part of the diff but a
git log -m -p 8d092c6
and search forsetBlockLocalVariables
will show it.Was it intentional to remove these calls?
What does JRuby use to get block-local variables?
The
ArgsNode
has no reference to it, the only way I see is throughthe IterNode's StaticScope, by the mean of looking at variableNames and noticing that the 4th entry belongs to none of the Signature indicies. Surely, there must be a better way?
The text was updated successfully, but these errors were encountered: