-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Param scope and body scope should not be merged on this case. #6290
base: master
Are you sure you want to change the base?
Conversation
When the param is used in the function, defined at the param scope, we should be have different param and body scope for the the enclosing function. However we are using the function id from the top ref of the pidRefStack. This is not correct as we could have pushed a ref on the stack with different block id but for the same function - so this logic could break. For fixing that we should walk that pidRefStack to see if there is access to the inner function.
So why isn’t the capture found when we do binding, which pops the stack? It shouldn’t be necessary to walk it like this. |
@pleath Because of deferparsing. As we already merged the param scope and body scope - but while restoring from the scopeinfo we don't have that detail anymore thus the param scope does not have anything (as they were merged already). |
I had a feeling. So this is really about the way the stack is reconstructed. |
the pidrefstack is ordered for block id. So we could not find out if the current symbol is used in the nested function. |
Binding does find all the non-local references without walking the stack. If there’s a problem that only occurs with deferred parsing, it’s almost certainly because things are not set up correctly when we read the scope info. That could cause other problems besides this one. |
Since we did not correctly find out that param scope and body scope need not merge - that put wrong information while saving the scope info. Later when restore when we did not restore the param scope. |
Okay. That makes sense. So the problem is not with binding or discovery of non-local references, which we do eventually find. It’s having incomplete information when we save scope info. Is that right? |
Yes. Moreover the ResetBodyandParamScopeMerge is using the incomplete information. Which eventually get stored in the scope info. |
Is there a reason we can’t wait until the information is complete before saving scope info? |
Looking at the code at ParseFncDeclHelper, it seems we make use of that information up-front to at the body scope creation and push those symbols to the body scope based on if they are needed to merge or not. |
When the param is used in the function, defined at the param scope, we should be have different param and body scope for the the enclosing function.
However we are using the function id from the top ref of the pidRefStack. This is not correct as we could have pushed a ref on the stack with different block id
but for the same function - so this logic could break.
For fixing that we should walk that pidRefStack to see if there is access to the inner function.