Skip to content

cmd/compile: panic message for failed assertion of generic type mentions shape type, not user type #53276

@mdempsky

Description

@mdempsky

https://go.dev/play/p/3Ru8nGnvTQY

The above program reports at run-time "panic: interface conversion: interface { T() go.shape.int_0 } is nil, not int".

I think the correct error is "panic: interface conversion: interface { T() int } is nil, not int".

The problem is the call to s.reflectType(src) in ssagen/ssa.go. This is too late to do dictionary lookups, so we end up using the *runtime._type for the shape type, rather than the user type.

We should push all the reflectdata.TypePtr / reflectdata.TypeLinksym calls earlier into the frontend, so they can be replaced with dictionary accesses when appropriate. Same applies to reflectdata.ITabAddr and reflectdata.ITabLSym.

/cc @randall77 @dr2chase @cuonglm

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions