Skip to content

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

Closed

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

Activity

  1. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    on Jun 7, 2022
  2. modified the milestones: Go1.19, Go1.20 on Jun 7, 2022
  3. gopherbot commented on Jun 10, 2022

    @gopherbot
    Contributor

    Change https://go.dev/cl/411695 mentions this issue: [dev.unified] test: add regress tests for #53276 and #53328

  4. gopherbot commented on Jun 21, 2022

    @gopherbot
    Contributor

    Change https://go.dev/cl/413357 mentions this issue: [dev.unified] cmd/compile: avoid reflectType in ssagen

  5. gopherbot commented on Aug 4, 2022

    @gopherbot
    Contributor

    Change https://go.dev/cl/421374 mentions this issue: all: REVERSE MERGE dev.unified (d558507) into master

  6. added a commit that references this issue on Aug 4, 2022
  7. cuonglm commented on Sep 30, 2022

    @cuonglm
    Member

    @mdempsky seems we can close this now?

  8. mdempsky commented on Sep 30, 2022

    @mdempsky
    ContributorAuthor

    @cuonglm Yes, thanks.

  9. Repository owner moved this from Triage Backlog to Done in Go Compiler / Runtime / Commandon Sep 30, 2022
  10. locked and limited conversation to collaborators on Sep 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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