mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-22 19:29:39 +00:00
compiler: fix a bug with type conversion in switch
It was incorrectly parsed as void call.
This commit is contained in:
parent
7560aa345a
commit
7d61a567d5
2 changed files with 20 additions and 0 deletions
|
@ -108,6 +108,11 @@ func (c *funcScope) analyzeVoidCalls(node ast.Node) bool {
|
|||
if ok {
|
||||
c.voidCalls[ce] = false
|
||||
}
|
||||
case *ast.SwitchStmt:
|
||||
ce, ok := n.Tag.(*ast.CallExpr)
|
||||
if ok {
|
||||
c.voidCalls[ce] = false
|
||||
}
|
||||
case *ast.CaseClause:
|
||||
for _, e := range n.List {
|
||||
ce, ok := e.(*ast.CallExpr)
|
||||
|
|
|
@ -33,6 +33,21 @@ var switchTestCases = []testCase{
|
|||
}`,
|
||||
big.NewInt(2),
|
||||
},
|
||||
{
|
||||
"type conversion in tag",
|
||||
`package main
|
||||
type state int
|
||||
func Main() int {
|
||||
a := 1
|
||||
switch state(a) {
|
||||
case 1:
|
||||
return 42
|
||||
default:
|
||||
return 11
|
||||
}
|
||||
}`,
|
||||
big.NewInt(42),
|
||||
},
|
||||
{
|
||||
"simple switch fail",
|
||||
`package main
|
||||
|
|
Loading…
Reference in a new issue