Commit b83a916f authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: make iface == iface const evaluation respect !=

Fixes #19911

Change-Id: Ib2b2505fe31ce00c6ffc021a0fe5df510633b44b
Reviewed-on: https://go-review.googlesource.com/40251
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent 44bd39c3
......@@ -815,6 +815,9 @@ func evconst(n *Node) {
// check for compatible general types (numeric, string, etc)
if wl != wr {
if wl == TINTER || wr == TINTER {
if n.Op == ONE {
goto settrue
}
goto setfalse
}
goto illegal
......
// run
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"fmt"
"strings"
)
type ET struct{}
func (*ET) Error() string { return "err" }
func main() {
check("false", fmt.Sprintf("(*ET)(nil) == error(nil): %v", (*ET)(nil) == error(nil)))
check("true", fmt.Sprintf("(*ET)(nil) != error(nil): %v", (*ET)(nil) != error(nil)))
nilET := (*ET)(nil)
nilError := error(nil)
check("false", fmt.Sprintf("nilET == nilError: %v", nilET == nilError))
check("true", fmt.Sprintf("nilET != nilError: %v", nilET != nilError))
}
func check(want, gotfull string) {
got := gotfull[strings.Index(gotfull, ": ")+len(": "):]
if got != want {
panic("want " + want + " got " + got + " from " + gotfull)
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment