// before key is fully defined, the error
// will only be printed for the first one.
// good enough.
- if key.Maplineno == 0 {
- key.Maplineno = lineno
+ if maplineno[key] == 0 {
+ maplineno[key] = lineno
}
}
}
Vargen int32 // unique name for OTYPE/ONAME
Lineno int32 // line at which this type was declared, implicitly or explicitly
- Maplineno int32 // first use of this type as a map key
-
Etype EType // kind of type
Noalg bool // suppress hash and eq algorithm generation
Trecur uint8 // to detect loops
checkwidth(n.Type)
}
-var mapqueue []*Node
+var (
+ mapqueue []*Node
+ // maplineno tracks the line numbers at which types are first used as map keys
+ maplineno = map[*Type]int32{}
+)
func copytype(n *Node, t *Type) {
if t.Etype == TFORW {
return
}
- maplineno := n.Type.Maplineno
+ mapline := maplineno[n.Type]
embedlineno := n.Type.ForwardType().Embedlineno
l := n.Type.ForwardType().Copyto
lineno = lno
// Queue check for map until all the types are done settling.
- if maplineno != 0 {
- t.Maplineno = maplineno
+ if mapline != 0 {
+ maplineno[t] = mapline
mapqueue = append(mapqueue, n)
}
}
}
for _, n := range mapqueue {
- lineno = n.Type.Maplineno
+ lineno = maplineno[n.Type]
checkMapKeyType(n.Type)
}