interp: fix switch expression (#1370)

The control flow graph was incorrect for the initial clause.

Fixes #1368.
This commit is contained in:
Marc Vertes
2022-04-06 22:07:51 +02:00
committed by GitHub
parent 8bd7afbe62
commit 371103f0d1
2 changed files with 17 additions and 0 deletions

16
_test/issue-1368.go Normal file
View File

@@ -0,0 +1,16 @@
package main
const dollar byte = 36
func main() {
var c byte = 36
switch true {
case c == dollar:
println("ok")
default:
println("not ok")
}
}
// Output:
// ok

View File

@@ -1832,6 +1832,7 @@ func (interp *Interpreter) cfg(root *node, sc *scope, importPath, pkgName string
setFNext(c, clauses[i+1])
}
}
sbn.start = clauses[0].start
n.start = n.child[0].start
n.child[0].tnext = sbn.start