-
Notifications
You must be signed in to change notification settings - Fork 928
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
Trying to implement reflect.New()
#1087
Comments
Quick explanation of what is happening: Type asserts are implemented by generating a switch statement. TinyGo tries to compute a list of all implementing types, and then generates a type switch across them. The way that TinyGo gets this list of all implementing types is by looking at every interface creation operation. In this case, you are synthesizing a type at runtime, and therefore the compiler does not discover the implementation.
Other synthesized types cannot implement non-empty interfaces, so we do not need any gigantic changes to how we handle this yet. |
Will we be able to get back to this PR soon? |
|
In that case, I am going to close this issue now. Thanks everyone! |
Hi,
I'm trying to implement the missing function
reflect.New()
in TinyGo, and here's my minimal patch:When testing it with the following sample code:
I got the error:
panic: runtime error: type assert failed
However, if I change the sample code a little bit, it then works fine:
It seems that somehow I need to make the compiler see a conversion from
*Foo
tointerface{}
.Do you have any insights on this? Thanks.
The text was updated successfully, but these errors were encountered: