-
-
Notifications
You must be signed in to change notification settings - Fork 670
ERROR TS2322: Type 'FooBar' is not assignable to type 'FooBar'. #539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Could you provide wasm or wat file with |
@MaxGraey compiler errors out, how would I provide .wasm file? To repro you can just check out my branch, do |
Ah, sorry, I missed this actually compiler error) |
@vgrichina I try to reproduce your issue in WAS with emulate generated "near_model" but everything compile in normal way: |
btw with latest AS version you could simplify this to: export function convertFoobars(foobars: FooBar[]): ContainerClass[] {
return foobars.map<ContainerClass>(it => ({ foobar: it }));
} |
While working on the runtime branch I hit an issue that might, potentially, be related to this. Essentially, if you have: namespace foo {
export const bar: i32 = somethingGeneric<Bar>();
class Bar {}
}
class Bar {} the resolver picks up the outer |
Finally! It just so happened that I reproduced this issue: namespace foo {
export class Bar {
a: i32;
}
}
class Bar {
a: f64;
}
function baz<T>(foo: T): i32 {
return foo.a;
}
var fooBar = new foo.Bar();
fooBar.a = 1;
baz<foo.Bar>(fooBar);
var bar = new Bar();
bar.a = 1;
baz<Bar>(bar); The underlying problem is that when a generic function becomes compiled, it is named after its type argument's name, ignoring nesting, hence the same function becomes shared for types of the same top-most name even though in different code locations, in turn leading to the described issue. The obvious fix here is to use a namespaced naming scheme, i.e. compile a Sorry that it took so long to confirm. |
For repro see nearprotocol#23
Go to
tests/near-bindgen
and run./test.sh
.It looks like #489 doesn't fully solve all name clash issues.
The text was updated successfully, but these errors were encountered: