Skip to content

Commit

Permalink
interp: fix switch expression (traefik#1370)
Browse files Browse the repository at this point in the history
The control flow graph was incorrect for the initial clause.

Fixes traefik#1368.
  • Loading branch information
mvertes authored Apr 6, 2022
1 parent 8bd7afb commit 371103f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions _test/issue-1368.go
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions interp/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 371103f

Please sign in to comment.