-
Notifications
You must be signed in to change notification settings - Fork 12
#136 fix a bug in scoping of the let clause #137
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
base: main
Are you sure you want to change the base?
Conversation
…ng with inner scoped let clause
|
@evan-gordon I realize maybe this could be broken into 2 PRs but the problem was cascading i was checking a ahrq cql file and the scoping issues had two bugs one for the let clause at the root and a second one for nesteed let clause within a sort clause |
Thanks for the context. |
evan-gordon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @vfrank66 !
This seems like a pretty good change overall, my main concern below is about making sure that this change properly cleans up aliases after the scope is exited properly. Once comments are addressed I'll approve.
| t.Errorf("ResolveLocal(A) = %v, want %v", got, "updated_value") | ||
| } | ||
|
|
||
| // Test error case - update non-existent alias |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind making this it's own test case?
| } | ||
| return av.Compare(bv) | ||
| case types.Integer: | ||
| av := ap.GolangValue().(int32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for all of these conversions you can use applyToValues(av, bp, result.ToInt32) to do the conversion for both values to the desired type.
| filteredIters := []iteration{} | ||
| for _, iter := range iters { | ||
| for _, relIter := range relIters { | ||
| i.refs.EnterScope() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My main concern with this change would be to check if it properly cleans up aliases, refs.EnterScope() and refs.ExitScope() should handle making sure aliases are correctly scoped for the right context.
Does this solution properly clean up it's values when exiting a specific scope? Perhaps we should add tests that:
- inside
TestCrossLibraryAliasResolutionquery1 declares a variableMcalls function that starts query2, that also declares a variableM.Min the outer context should still be the right value after the inner query runs. - An error case where similar to the above case, but the outer query doesn't define
M, ifMis referenced after the inner query it should throw some meaningful error about the identifier not being declared in this scop.
No description provided.