-
-
Notifications
You must be signed in to change notification settings - Fork 672
ERROR AS200: Conversion from type '__near_JSONHandler_Todo' to '__near_JSONHandler_Todo' requires an explicit cast. #429
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
I tried minimal example on original WAS and can't reproduce this error: Also you could implicate |
This doesn't help. I think I know more now about how to trigger this. I actually had 2 different definitions of |
AssemblyScript#429 This fix changes bindings generation to only generate each encode / decode function once, so that they don’t clash names.
If I understand this correctly there are two distinct classes with the same name and the same structural layout, being used interchangeable, is that correct? If so, the error is expected because AS can't just rely on structural equality like TS does. One example where this would fail is when field order differs between two otherwise equal types, which TS would consider equal, but AS can't because AOT compiled class A {
a: i32; // offset 0
b: f32; // offset 4
}
class B {
b: f32; // offset 0
a: i32; // offset 4
} In this sense AS is more like C#/Java here (currently). Might well be that we'll have to tackle this at some point when it comes to interfaces. |
No, this is not correct. See failing code snippet above. It cannot be referring to 2 distinct types. There is type with same name in 2 different modules. But only one should be available in namespace of the given module. |
Hmm, ok, still trying to understand what's going on there. There's one
The error happens in [import] at export function __near_decode_Todo(
buffer: Uint8Array,
state: DecoderState
): wrapped_Todo {
let handler = new __near_JSONHandler_Todo();
handler.buffer = buffer;
handler.decoder = new JSONDecoder<__near_JSONHandler_Todo>(handler); // HERE
handler.decoder.deserialize(buffer, state);
return handler.value;
} Which is called in Might need to isolate the issue, maybe copying it and deleting anything not relevant to the issue first, leaving just the gist leading to the error. |
Closing in favor of #473, which is our tracking issue for similar related issues now. |
The resolver PR that should fix this issue if our previous speculation was correct has been merged now. Could you check if the issue still persists? |
@dcodeIO the issue still persists |
It appears to me that this isn't actually an issue with the resolver, but is introduced by something else. Unfortunately, I find it hard to work with the fork because it requires dissecting code that is partly generated by hardcoded changes to the compiler and it is unclear to me how this all works. Perhaps it makes sense to first remedy the situation of having to do hardcoded changes at all as indicated by comments like |
I get this error when compiling example here (clicking Deploy):
https://studio.nearprotocol.com/?f=mpijex6n4
Code snippet with problem is:
Note clear why these types are treated as different.
The text was updated successfully, but these errors were encountered: