Skip to content

Conversation

@vfrank66
Copy link
Contributor

No description provided.

@vfrank66
Copy link
Contributor Author

@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

@evan-gordon
Copy link
Contributor

@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.

Copy link
Contributor

@evan-gordon evan-gordon left a 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
Copy link
Contributor

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)
Copy link
Contributor

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()
Copy link
Contributor

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:

  1. inside TestCrossLibraryAliasResolution query1 declares a variable M calls function that starts query2, that also declares a variable M. M in the outer context should still be the right value after the inner query runs.
  2. An error case where similar to the above case, but the outer query doesn't define M, if M is referenced after the inner query it should throw some meaningful error about the identifier not being declared in this scop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants