You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 20, 2022. It is now read-only.
Parsing and type-checking works fine. Type parameters are internally considered to have underlying type interface{} so you are allowed to use a type switch on them in the body of a function. But ultimately it fails because the generated Go code looks like this:
In Go, you can't use a type switch on non-interface types like int. However, it should not be too difficult for the Fo compiler to remove the type switch from the AST when it already knows the type. The generated Go code would then look like this:
In Go, you can't use a type switch on non-interface types like int. However, it should not be too difficult for the Fo compiler to remove the type switch from the AST when it already knows the type.
You could also cast the parameter to an interface {}
switchx:= (interface {})(x).(type)
If that was easier - the go compiler will then prune the switch for you.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Can one type switch within the implementation of a generic function? something like this might be reasonable:
The text was updated successfully, but these errors were encountered: