Reject type refinements unless of numeric types

This commit is contained in:
Nigel Tao committed 2021-01-15 16:04:18 +11:00
1 parent afc6bb9ec3
commit f58db5a4d8
1 file changed
+6
+6
View File
@@ -556,6 +556,12 @@ func (p *parser) parseTypeExpr() (*a.TypeExpr, error) {
if err != nil {
return nil, err
}
if name.IsNumType() &&
((pkg == t.IDBase) || ((pkg == 0) && p.opts.AllowBuiltInNames)) {
// No-op.
} else {
return nil, fmt.Errorf(`parse: cannot refine non-numeric type at %s:%d`, p.filename, p.line())
}
}
return a.NewTypeExpr(0, pkg, name, lhs.AsNode(), mhs, nil), nil