Closed charlesstaats closed 3 months ago
This simplified example
struct U {
struct B {}
}
struct A {}
A g() {return new A;}
void f(U.B) {}
f(g());
generates the same strange error message:
f(g());
^
test.asy: 11.2: cannot call 'void f(B)' with parameter '(A)'
I think the only issue here is that the error message should read:
test.asy: 11.2: cannot call 'void f(U.B)' with parameter 'A'
In the example you found, there should be an error. In the example I proposed, there should not be any error: the expected argument type and the actual argument type are both the A_T
defined in structA(T=int)
. But the compiler fails to recognize that the two A_int
types are in fact the same type.
Sorry, I was distracted by the extra parentheses around the function argument in the error message (this cosmetic issue has incidentally now been fixed in 337b9f3786c808e746aa0446784821813e5b0f4c). Charles and I just noticed that this issue was a byproduct of redundant templated imports with identical signatures, which was fixed in commit 3429cdc71e39e53a08f1784137bcbf4fc7599fde.
I think it's best to give an example, which will consist of three short files.
structA.asy
:structB.asy
:test.asy
:Action: run
asy test
.Expected result: Asymptote runs successfully and produces no output.
Actual result: we get the following nonsensical-sounding error:
I have tried and failed to reproduce this error without using templated imports. However, there may be something I am missing. So I still cannot guarantee that this error has anything to do with templates.
Workaround
In
test.asy
, access everything fromstructB
, even ifstructB
gets it fromstructA
: