Skip to content

Commit

Permalink
Fix bug: default 'except_' should appear at last
Browse files Browse the repository at this point in the history
  • Loading branch information
hsfzxjy committed Feb 7, 2021
1 parent 73c228d commit 9091565
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lambdex/compiler/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ def r_try(node: ast.Subscript, ctx: Context, clauses: list):
handlers = []
orelse_body = []
final_body = []
default_except_clause = None
for clause in clauses[1:]:
if clause.name == 'except_':
ctx.assert_(
Expand All @@ -298,8 +299,14 @@ def r_try(node: ast.Subscript, ctx: Context, clauses: list):
if clause.no_head():
# bare except
type_ = name = None
default_except_clause = clause
else:
# except with capturing
ctx.assert_(
default_except_clause is None,
"default 'except_' must be last",
lambda: default_except_clause.node,
)
ctx.assert_single_head(clause)
type_, name = check_as(ctx, clause.unwrap_head(), ast.Gt, rhs_is_identifier=True)

Expand Down

0 comments on commit 9091565

Please sign in to comment.