16597, “dlongnecke-cray”, “Call to imported function within a generic function fails to resolve”, “2020-10-16T21:19:28Z”
While writing some code, I needed to use the Reflection
module to conditionally call a function. What I found is that when I imported a single function from Reflection
, it failed to resolve when I called it.
This is a simplified reproducer of what I was attempting to do. It fails to resolve the call to canResolve
:
proc foo() {
writeln('foo');
}
proc test(param x=1) {
import Reflection.canResolve;
if canResolve('foo') then
foo();
}
test();
TestImportFailure.chpl:5: In function 'test':
TestImportFailure.chpl:7: error: unresolved call 'canResolve("foo")'
TestImportFailure.chpl:7: note: because no functions named canResolve found in scope
This alternative way of writing it does work, but isn’t ideal because it imports all of Reflection
:
proc foo() {
writeln('foo');
}
proc test(param x=1) {
import Reflection;
if Reflection.canResolve('foo') then
foo();
}
test();