Skip to content

Commit

Permalink
Revert "Revert "fix(rivetc): fix inappropriate behavior of defer wi…
Browse files Browse the repository at this point in the history
…th `break`""

This reverts commit 2301950.
  • Loading branch information
StunxFS committed Nov 12, 2023
1 parent 76e7311 commit 4c5feff
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/rivet/src/ast/Stmt.ri
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public enum Stmt {
pos: token.Pos;
},
Defer {
public enum Mode {
public enum Mode as uint8 {
Normal,
Error,
Success
Expand Down
3 changes: 1 addition & 2 deletions rivetc/src/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,11 +816,10 @@ def __str__(self):
return self.__repr__()

class BranchExpr:
def __init__(self, op, pos, scope = None):
def __init__(self, op, pos):
self.op = op
self.pos = pos
self.typ = None
self.scope = scope

def __repr__(self):
return str(self.op)
Expand Down
1 change: 0 additions & 1 deletion rivetc/src/codegen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2330,7 +2330,6 @@ def gen_expr(self, expr, custom_tmp = None):
self.gen_expr(self.while_continue_expr)
self.cur_fn.add_br(self.loop_entry_label)
else:
self.gen_defer_stmts(scope = expr.scope)
self.cur_fn.add_br(self.loop_exit_label)
return ir.Skip()
elif isinstance(expr, ast.ReturnExpr):
Expand Down
2 changes: 1 addition & 1 deletion rivetc/src/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ def parse_primary_expr(self):
op = self.tok.kind
pos = self.tok.pos
self.next()
expr = ast.BranchExpr(op, pos, self.scope)
expr = ast.BranchExpr(op, pos)
elif self.accept(Kind.KwReturn):
pos = self.prev_tok.pos
has_expr = self.tok.kind not in (
Expand Down

0 comments on commit 4c5feff

Please sign in to comment.