lang: core: Lookup function (with default) can be more precise

This commit is contained in:
James Shubin
2025-01-26 18:48:53 -05:00
parent 3f202c6a7a
commit 6268b61a7d

View File

@@ -97,8 +97,8 @@ func (obj *LookupDefaultFunc) Build(typ *types.Type) (*types.Type, error) {
return nil, fmt.Errorf("input type must be of kind func") return nil, fmt.Errorf("input type must be of kind func")
} }
if len(typ.Ord) < 1 { if len(typ.Ord) != 3 {
return nil, fmt.Errorf("the lookup function needs at least one arg") // actually 2 or 3 return nil, fmt.Errorf("the lookup function needs three args")
} }
tListOrMap, exists := typ.Map[typ.Ord[0]] tListOrMap, exists := typ.Map[typ.Ord[0]]
if !exists || tListOrMap == nil { if !exists || tListOrMap == nil {