-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed as not planned
Closed as not planned
Copy link
Labels
FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.Proposalv2An incompatible library changeAn incompatible library change
Milestone
Description
Currently, if a method is defined on a value type, that method is also
part of the method set of the pointer type. However, if that method
is called on the nil pointer, it panics.
This means there's no way to define a method that works on all possible
values and pointer values for a type.
I propose that when a value method is called on a nil pointer, instead of panicking,
the method is invoked on the zero value for the type.
As this breaks code that currently relies on catching this panic (notably the
fmt package), it is probably sufficiently backwardly incompatible to justify
the Go2 tag.
DeedleFake, mvdan, overcyn, mh-cbon, nanasi880 and 2 moretmthrgd and empijei
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.Proposalv2An incompatible library changeAn incompatible library change