mirror of
https://github.com/golang/go.git
synced 2025-05-23 00:11:26 +00:00
cmd/compile: convert untyped bool during walkCases
Updates #23834. Change-Id: I1789525a992d37aae9e9b69c1e9d91437d3d0d3b Reviewed-on: https://go-review.googlesource.com/97001 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
2413b54888
commit
a375a6b363
@ -315,16 +315,19 @@ func (s *exprSwitch) walkCases(cc []caseClause) *Node {
|
||||
high := nod(OLE, s.exprname, rng[1])
|
||||
a.Left = nod(OANDAND, low, high)
|
||||
a.Left = typecheck(a.Left, Erv)
|
||||
a.Left = defaultlit(a.Left, nil)
|
||||
a.Left = walkexpr(a.Left, nil) // give walk the opportunity to optimize the range check
|
||||
} else if (s.kind != switchKindTrue && s.kind != switchKindFalse) || assignop(n.Left.Type, s.exprname.Type, nil) == OCONVIFACE || assignop(s.exprname.Type, n.Left.Type, nil) == OCONVIFACE {
|
||||
a.Left = nod(OEQ, s.exprname, n.Left) // if name == val
|
||||
a.Left = typecheck(a.Left, Erv)
|
||||
a.Left = defaultlit(a.Left, nil)
|
||||
} else if s.kind == switchKindTrue {
|
||||
a.Left = n.Left // if val
|
||||
} else {
|
||||
// s.kind == switchKindFalse
|
||||
a.Left = nod(ONOT, n.Left, nil) // if !val
|
||||
a.Left = typecheck(a.Left, Erv)
|
||||
a.Left = defaultlit(a.Left, nil)
|
||||
}
|
||||
a.Nbody.Set1(n.Right) // goto l
|
||||
|
||||
@ -354,6 +357,7 @@ func (s *exprSwitch) walkCases(cc []caseClause) *Node {
|
||||
a.Left = le
|
||||
}
|
||||
a.Left = typecheck(a.Left, Erv)
|
||||
a.Left = defaultlit(a.Left, nil)
|
||||
a.Nbody.Set1(s.walkCases(cc[:half]))
|
||||
a.Rlist.Set1(s.walkCases(cc[half:]))
|
||||
return a
|
||||
|
Loading…
x
Reference in New Issue
Block a user