Skip to content

Commit

Permalink
chore: add sanity check in parse_BinOp
Browse files Browse the repository at this point in the history
add sanity check in parse_BinOp, we can be stricter in the case where
it's a shift binop.

chainsec june review 5.4
  • Loading branch information
charles-cooper committed Aug 27, 2023
1 parent 43c8d85 commit 106954b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions vyper/codegen/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,17 @@ def parse_BinOp(self):
left = Expr.parse_value_expr(self.expr.left, self.context)
right = Expr.parse_value_expr(self.expr.right, self.context)

if not isinstance(self.expr.op, (vy_ast.LShift, vy_ast.RShift)):
is_shift_op = isinstance(self.expr.op, (vy_ast.LShift, vy_ast.RShift))

if is_shift_op:
assert is_numeric_type(left.typ)
# Sanity check - ensure that we aren't dealing with different types
# This should be unreachable due to the type check pass
if left.typ != right.typ:
raise TypeCheckFailure(f"unreachable, {left.typ} != {right.typ}", self.expr)
else:
assert is_numeric_type(left.typ) or is_enum_type(left.typ)

assert is_numeric_type(left.typ) or is_enum_type(left.typ)

out_typ = left.typ

Expand Down

0 comments on commit 106954b

Please sign in to comment.