Function can't be invoked with typed null argument at runtime
duncand opened this issue · comments
Darren Duncan commented
This issue is similar to issue #74.
Passing a typed null as an argument to a function succeeds in Translation but fails at runtime citing "could not resolve call to operator".
See this example CQL:
define x: f1('hello')
define y: f1(null as String)
define z: f2(null as String)
define w: f2('world')
define function f1(arg String) returns String: arg
define function f2(arg List<String>) returns String: SingletonFrom(arg)
And the result of running it:
>> x [1:1] hello
>> z [3:1] Null
>> w [4:1] world
>> f1 [5:1] Definition successfully validated
>> f2 [6:1] Definition successfully validated
>> Error: Could not resolve call to operator 'f1' in library 'null'.
While it is reasonable for an untyped null argument to fail resolution, here we have a null explicitly cast as the declared parameter type, which is also failing.
Note that the same workaround for issue #74 also works here, wrapping the parameter in a singleton List, as also shown in the above example.
The task of this ticket is to fix the Engine so the workaround isn't necessary.