Skip to content
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

Type.AssignableTo panics with "reflect: unimplemented: AssignableTo with interface" #4277

Open
fxamacker opened this issue May 28, 2024 · 0 comments
Labels
reflection Needs further work on reflection

Comments

@fxamacker
Copy link

Some packages like fxamacker/cbor require Type.AssignableTo to support Interface.

There was some prior discussion at fxamacker/cbor#295 (comment).

Projects using packages that require Interface support can encounter panics from the following code.

tinygo/src/reflect/type.go

Lines 956 to 969 in 6384eca

func (t *rawType) AssignableTo(u Type) bool {
if t == u.(*rawType) {
return true
}
if u.Kind() == Interface && u.NumMethod() == 0 {
return true
}
if u.Kind() == Interface {
panic("reflect: unimplemented: AssignableTo with interface")
}
return false
}

If a solution becomes available, I can use some existing tests in fxamacker/cbor to help test it.

fxamacker added a commit to fxamacker/cbor that referenced this issue Sep 8, 2024
tinygo v0.33 doesn't implement Type.AssignableTo(), which is
needed under the hood when decoding registered CBOR tag data
to Go interface.

More details in tinygo-org/tinygo#4277.

This commit returns error of UnmarshalTypeError type when
decoding registered CBOR tag data to Go interface.

This change can be reverted after tinygo implements
Type.AssignalbeTo().
@deadprogram deadprogram added the reflection Needs further work on reflection label Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reflection Needs further work on reflection
Projects
None yet
Development

No branches or pull requests

2 participants