lang: add read-only type decorators

This commit is contained in:
Nigel Tao committed 2023-04-10 15:29:12 +10:00
1 parent 6e8349129c
commit f3caf09d77
14 files changed
+132 -77

No files matched your search

+13 -7
View File
@@ -182,23 +182,29 @@ func (c *Checker) resolveFunc(typ *a.TypeExpr) (*a.Func, error) {
lQID := lTyp.QID()
qqid := t.QQID{lQID[0], lQID[1], typ.FuncName()}
if lTyp.IsSliceType() {
if lTyp.IsEitherSliceType() {
qqid[0] = t.IDBase
qqid[1] = t.IDDagger1
if f := c.builtInSliceFuncs[qqid]; f != nil {
return f, nil
}
if lTyp.Eq(typeExprSliceU8) {
if f := c.builtInSliceU8Funcs[qqid]; f != nil {
if (lTyp.Decorator() == t.IDSlice) || f.Effect().Pure() {
return f, nil
}
}
if lTyp.Eq(typeExprSliceU8) {
if f := c.builtInSliceU8Funcs[qqid]; f != nil {
if (lTyp.Decorator() == t.IDSlice) || f.Effect().Pure() {
return f, nil
}
}
}
} else if lTyp.IsTableType() {
} else if lTyp.IsEitherTableType() {
qqid[0] = t.IDBase
qqid[1] = t.IDDagger2
if f := c.builtInTableFuncs[qqid]; f != nil {
return f, nil
if (lTyp.Decorator() == t.IDTable) || f.Effect().Pure() {
return f, nil
}
}
} else if f := c.funcs[qqid]; f != nil {