You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CQL allows overloaded functions and forward declarations but not recursion. This means that it's valid for a function to reference a "yet to be defined" overload of itself. Here's an example:
define function toString(value Concept):
if value is null
then 'null'
// The reference here to toString(value List<System.Code>) should _not_ result in a circular reference error
// The function signature is distinct, therefore is should be considered a different function.
else 'Concept { ' + toString(value.codes) + ' display: ' + value.display + ' }'
define function toString(value List<System.Code>):
Combine(
value C return 'Code: ' + C.display,
', '
)
Here there are two overloads for "toString", one for a Concept and one for a List<System.Code>
If this file is compiled top-down, the definition for the Concept overload is encountered first. At the point in compilation of the Concept overload where it needs to work out the reference to the List<System.Code> overload, it should determine that the List<System.Code> overload is yet to be defined and compile that function.
The current buggy behavior is that the compiler tries to pick from the set of "toString" delcarations in the CQL file, finds the function that it's currently compiling, and throws a circular reference error. In other words, the function that's currently being compiled is incorrectly detected as a candidate for a forward declaration.
There's a test already set up that reproduces this behavior here:
CQL allows overloaded functions and forward declarations but not recursion. This means that it's valid for a function to reference a "yet to be defined" overload of itself. Here's an example:
Here there are two overloads for "toString", one for a Concept and one for a List<System.Code>
If this file is compiled top-down, the definition for the Concept overload is encountered first. At the point in compilation of the Concept overload where it needs to work out the reference to the List<System.Code> overload, it should determine that the List<System.Code> overload is yet to be defined and compile that function.
The current buggy behavior is that the compiler tries to pick from the set of "toString" delcarations in the CQL file, finds the function that it's currently compiling, and throws a circular reference error. In other words, the function that's currently being compiled is incorrectly detected as a candidate for a forward declaration.
There's a test already set up that reproduces this behavior here:
clinical_quality_language/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/LibraryTests.java
Line 440 in 843f17f
The bug is likely in the forward declaration code which is here:
clinical_quality_language/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/Cql2ElmVisitor.java
Lines 4435 to 4463 in 2d799ae
The text was updated successfully, but these errors were encountered: