Add a TypeExpr type expression

This commit is contained in:
Nigel Tao committed 2018-07-07 21:57:15 +10:00
1 parent 295cbbccae
commit 731ca8841b
5 files changed
+39 -29

No files matched your search

+12 -8
View File
@@ -682,17 +682,21 @@ func allTypeChecked(tm *t.Map, n *a.Node) error {
return fmt.Errorf("check: internal error: unchecked %s", nodeDebugString(tm, o))
}
typOK := false
switch o.Kind() {
default:
if typ != typeExprPlaceholder {
return fmt.Errorf("check: internal error: %s does not have placeholder type", nodeDebugString(tm, o))
}
case a.KExpr:
if typ == typeExprPlaceholder {
return fmt.Errorf("check: internal error: %s has placeholder type", nodeDebugString(tm, o))
}
typOK = typ != typeExprPlaceholder && typ != typeExprTypeExpr
case a.KTypeExpr:
typOK = typ == typeExprTypeExpr
default:
typOK = typ == typeExprPlaceholder
}
if !typOK {
return fmt.Errorf("check: internal error: %s has incorrect type, %s",
nodeDebugString(tm, o), typ.Str(tm))
}
if o.Kind() == a.KExpr {
o := o.AsExpr()
if typ.IsIdeal() && o.ConstValue() == nil {
return fmt.Errorf("check: internal error: expression %q has ideal number type "+