aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder/reader.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/compile/internal/noder/reader.go')
-rw-r--r--src/cmd/compile/internal/noder/reader.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/noder/reader.go b/src/cmd/compile/internal/noder/reader.go
index 73e4ddbbed..dd3bb1523e 100644
--- a/src/cmd/compile/internal/noder/reader.go
+++ b/src/cmd/compile/internal/noder/reader.go
@@ -1676,6 +1676,20 @@ func (r *reader) expr() (res ir.Node) {
typ := r.typ()
pos := r.pos()
x := r.expr()
+
+ // TODO(mdempsky): Stop constructing expressions of untyped type.
+ x = typecheck.DefaultLit(x, typ)
+
+ if op, why := typecheck.Convertop(x.Op() == ir.OLITERAL, x.Type(), typ); op == ir.OXXX {
+ // types2 ensured that x is convertable to typ under standard Go
+ // semantics, but cmd/compile also disallows some conversions
+ // involving //go:notinheap.
+ //
+ // TODO(mdempsky): This can be removed after #46731 is implemented.
+ base.ErrorfAt(pos, "cannot convert %L to type %v%v", x, typ, why)
+ base.ErrorExit() // harsh, but prevents constructing invalid IR
+ }
+
return typecheck.Expr(ir.NewConvExpr(pos, ir.OCONV, typ, x))
}
}