You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was just working on some program in a code base that uses the suffix Id for a field,
but assigning from an struct from another codebase that uses ID instead.
For example given https://play.golang.org/p/9FAMV7mLZE
tmp/sandbox912846952/main.go:9:7: i1.Id undefined (type *it has no field or method Id, but does have ID)
tmp/sandbox912846952/main.go:11:14: unknown field 'Id'in struct literal of type it
Notice the nice hint on line 9 i1.Id undefined (type *it has no field or method Id, but does have ID)
it would be nice(though lengthy) to give a hint on line 14 such as
tmp/sandbox000177384/main.go:11:14: unknown field 'Id'in struct literal of type it (but does have ID)
griesemer
changed the title
proposal: cmd/compile: invalid but case insensitive field assignments should give hints
cmd/compile: better error message for wrong-cased field name in composite literal
Nov 18, 2017
I was just working on some program in a code base that uses the suffix
Id
for a field,but assigning from an struct from another codebase that uses
ID
instead.For example given https://play.golang.org/p/9FAMV7mLZE
on trying to compile it I get
Notice the nice hint on line 9
i1.Id undefined (type *it has no field or method Id, but does have ID)
it would be nice(though lengthy) to give a hint on line 14 such as
/cc compiler squad @mdempsky @griesemer @randall77 @rsc.
This is a super low priority issue that I can work on when free(or anyone else is welcome too), ideas and vetoes welcome.
The text was updated successfully, but these errors were encountered: