mirror of
https://github.com/golang/go
synced 2024-11-21 18:14:42 -07:00
gc: fix string comparisons for new bool rules
The two string comparison optimizations were missing the implicit cast from ideal bool. Fixes #3119. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5696071
This commit is contained in:
parent
fc268acf05
commit
564a1f3358
@ -1017,6 +1017,7 @@ walkexpr(Node **np, NodeList **init)
|
||||
r = nod(n->etype, nod(OLEN, n->left, N), nod(OLEN, n->right, N));
|
||||
typecheck(&r, Erv);
|
||||
walkexpr(&r, init);
|
||||
r->type = n->type;
|
||||
n = r;
|
||||
goto ret;
|
||||
}
|
||||
@ -1029,6 +1030,7 @@ walkexpr(Node **np, NodeList **init)
|
||||
r = nod(n->etype, nod(OLEN, n->left->left, N), nodintconst(0));
|
||||
typecheck(&r, Erv);
|
||||
walkexpr(&r, init);
|
||||
r->type = n->type;
|
||||
n = r;
|
||||
goto ret;
|
||||
}
|
||||
|
17
test/fixedbugs/bug425.go
Normal file
17
test/fixedbugs/bug425.go
Normal file
@ -0,0 +1,17 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2012 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.
|
||||
|
||||
// http://code.google.com/p/go/issues/detail?id=3119
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
s := "hello"
|
||||
fmt.Println(s == "")
|
||||
fmt.Println(s + "world" == "world")
|
||||
}
|
Loading…
Reference in New Issue
Block a user