Add built-in table T methods

This commit is contained in:
Nigel Tao committed 2018-05-18 12:50:53 +10:00
1 parent eda326726a
commit e4320c3c6d
21 files changed
+194 -5

No files matched your search

+11
View File
@@ -617,6 +617,17 @@ func (q *checker) tcheckDot(n *a.Expr, depth uint32) error {
n.SetMType(a.NewTypeExpr(t.IDFunc, 0, n.Ident(), lTyp.Node(), nil, nil))
return nil
} else if lTyp.IsTableType() {
qqid[0] = t.IDBase
qqid[1] = t.IDDiamond
if f, err := q.c.builtInTableFunc(qqid); err != nil {
return err
} else if f == nil {
return fmt.Errorf("check: no table method %q", n.Ident().Str(q.tm))
}
n.SetMType(a.NewTypeExpr(t.IDFunc, 0, n.Ident(), lTyp.Node(), nil, nil))
return nil
} else if lTyp.Decorator() != 0 {
return fmt.Errorf("check: invalid type %q for dot-expression LHS %q", lTyp.Str(q.tm), lhs.Str(q.tm))
}