aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder/validate.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/compile/internal/noder/validate.go')
-rw-r--r--src/cmd/compile/internal/noder/validate.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/noder/validate.go b/src/cmd/compile/internal/noder/validate.go
index 3341de8e04..b926222c89 100644
--- a/src/cmd/compile/internal/noder/validate.go
+++ b/src/cmd/compile/internal/noder/validate.go
@@ -23,10 +23,14 @@ func (g *irgen) match(t1 *types.Type, t2 types2.Type, hasOK bool) bool {
}
if hasOK {
- // For has-ok values, types2 represents the expression's type as
- // a 2-element tuple, whereas ir just uses the first type and
- // infers that the second type is boolean.
- return tuple.Len() == 2 && types.Identical(t1, g.typ(tuple.At(0).Type()))
+ // For has-ok values, types2 represents the expression's type as a
+ // 2-element tuple, whereas ir just uses the first type and infers
+ // that the second type is boolean. Must match either, since we
+ // sometimes delay the transformation to the ir form.
+ if tuple.Len() == 2 && types.Identical(t1, g.typ(tuple.At(0).Type())) {
+ return true
+ }
+ return types.Identical(t1, g.typ(t2))
}
if t1 == nil || tuple == nil {