cmd/cgo: erroneously allows methods declared on C types #39205
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
FrozenDueToAge
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
As reported at #35721 (comment), this code currently builds:
This is because cmd/cgo rewrites
C.int
into_Ctype_int
, which is a valid type to declare as a receiver parameter. However, this violates the abstraction of treating "C" as a separate package, as you can't normally declare methods on types imported from other packages.Fixing this probably just amounts to having cmd/cgo reject
C.foo
identifiers within receiver parameter types, but this also risks breaking existing code that relies on this./cc @ianlancetaylor
The text was updated successfully, but these errors were encountered: