token.Token inlines Pos rather than having it as a member:
type Token struct {
Type
Lit []byte
Pos
}
This means that in the absence of it's own String() method, token.String() is actually Pos.String(), which means that printing a token actually prints its position?
but what the user probably expected would have been
fubar fubar
This could be fixed:
Give Token it's own String() so that if you want the pos you use token.Pos.String(); could break existing code (if someone is relying on it to print Pos(offset=...)?)
token.Token
inlinesPos
rather than having it as a member:This means that in the absence of it's own
String()
method,token.String()
is actuallyPos.String()
, which means that printing a token actually prints its position?outputs:
but what the user probably expected would have been
This could be fixed:
token.Pos.String()
; could break existing code (if someone is relying on it to printPos(offset=...)
?)I've only been using go for a year or two, so I thought the go style was to put inheritances at the top and totally missed
Pos
vsPos Pos
.