Skip to content

cmd/compile: embedding comparable is not considered in calculating type sets #51472

Closed

Description

@zigo101

What version of Go are you using (go version)?

$ go version
go version go1.18rc1 linux/amd64

What did you do?

package main

func main() {
	foo("Abc")
	foo([]byte{}) // compiles okay, but should not
}

type C interface {
	comparable
	[]byte | string
}
	
func foo[T C](x T) {}

What did you expect to see?

Fails to compile.

What did you see instead?

Compiles okay.

Activity

  1. ianlancetaylor commented on Mar 4, 2022

    @ianlancetaylor
    Contributor
  2. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Mar 4, 2022
  3. added this to the Go1.18 milestone on Mar 4, 2022
  4. changed the title [-]cmd/compile: it looks embedding comprable is not considered in calculating tyep sets[/-] [+]cmd/compile: it looks embedding comparable is not considered in calculating type sets[/+] on Mar 4, 2022
  5. changed the title [-]cmd/compile: it looks embedding comparable is not considered in calculating type sets[/-] [+]cmd/compile: embedding comparable is not considered in calculating type sets[/+] on Mar 4, 2022
  6. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    on Mar 4, 2022
  7. self-assigned this
    on Mar 4, 2022
  8. added and removed
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Mar 4, 2022
  9. griesemer commented on Mar 4, 2022

    @griesemer
    Contributor

    Briefly looked at this. It appears we're forgetting to consider the "comparable" field in typesets under some circumstances. Appears like a trivial oversight, as the actual type set computations are ok. Will fix tomorrow.

  10. griesemer commented on Mar 4, 2022

    @griesemer
    Contributor

    Quick update: fix is pending but given that we're so short before the release, I'll spend some time adding more tests; this shouldn't have slipped. CL probably later today or tomorrow.

  11. gopherbot commented on Mar 4, 2022

    @gopherbot
    Contributor

    Change https://go.dev/cl/390025 mentions this issue: types2: correctly include comparable in type set intersection

  12. gopherbot commented on Mar 7, 2022

    @gopherbot
    Contributor

    Change https://go.dev/cl/390419 mentions this issue: [release-branch.go1.18] go/types, types2: correctly include comparable in type set intersection

  13. added a commit that references this issue on Mar 8, 2022
    f913f9d
  14. locked and limited conversation to collaborators on Jun 22, 2023
  15. added a commit that references this issue on Apr 29, 2024
    7dc6c5e
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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions