Skip to content

Commit 6485815

Browse files
committed
fix empty select statement (fixes #436)
1 parent 14ba2f5 commit 6485815

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

compiler/statements.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,10 +510,12 @@ func (c *funcContext) translateStmt(stmt ast.Stmt, label *types.Label) {
510510
c.Blocking[selectCall] = !hasDefault
511511
c.Printf("%s = %s;", selectionVar, c.translateExpr(selectCall))
512512

513-
translateCond := func(cond ast.Expr) *expression {
514-
return c.formatExpr("%s[0] === %e", selectionVar, cond)
513+
if len(caseClauses) != 0 {
514+
translateCond := func(cond ast.Expr) *expression {
515+
return c.formatExpr("%s[0] === %e", selectionVar, cond)
516+
}
517+
c.translateBranchingStmt(caseClauses, nil, true, translateCond, label, flattened)
515518
}
516-
c.translateBranchingStmt(caseClauses, nil, true, translateCond, label, flattened)
517519

518520
case *ast.EmptyStmt:
519521
// skip

0 commit comments

Comments
 (0)