Skip to content

Commit 79b119d

Browse files
committed
Fix assert statement
1 parent a27bc28 commit 79b119d

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

parser/grammar.y

+7-11
Original file line numberDiff line numberDiff line change
@@ -915,17 +915,13 @@ tests:
915915
}
916916

917917
assert_stmt:
918-
ASSERT tests
919-
{
920-
tests := $2
921-
switch len(tests) {
922-
case 1:
923-
$$ = &ast.Assert{StmtBase: ast.StmtBase{$<pos>$}, Test: tests[0]}
924-
case 2:
925-
$$ = &ast.Assert{StmtBase: ast.StmtBase{$<pos>$}, Test: tests[0], Msg: tests[1]}
926-
default:
927-
yylex.Error("Invalid syntax")
928-
}
918+
ASSERT test
919+
{
920+
$$ = &ast.Assert{StmtBase: ast.StmtBase{$<pos>$}, Test: $2}
921+
}
922+
| ASSERT test ',' test
923+
{
924+
$$ = &ast.Assert{StmtBase: ast.StmtBase{$<pos>$}, Test: $2, Msg: $4}
929925
}
930926

931927
compound_stmt:

0 commit comments

Comments
 (0)