cmd/compile/internal/types: add Type.UniqueString method #34250
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Currently, Type has three methods for converting into a string: String, LongString, and ShortString.
However, none of them uniquely identify the type. That is, there's currently no FooString such that t1.FooString() == t1.FooString() if and only if Identical(t1, t2).
I also suspect that many (if not all) of the current uses of Type.{Short,Long}String would be better served by a Type.UniqueString method.
Incidentally, ShortString and LongString are oddly named: LongString qualifies identifiers with merely the package name, whereas ShortString uses the full package path (thus generating longer strings than LongString normally does).
Currently, ShortString seems like the closest contender for UniqueString, but there are at least few issues I've noticed so far:
This seems to be because of the
if s.Name == "_" { return "_" }
special case in sconv.type myint = int
, thenstruct { myint }
prints as simplystruct { int }
). There's no Go syntax to handle this, so probably we'll need to invent something likestruct { myint = int }
. (We can't format asstruct { myint int }
, because that's another distinct type.)(I suspect the latter two can be turned into contrived linker failures today.)
The text was updated successfully, but these errors were encountered: