Skip to content

Commit

Permalink
fix: error messages on some safemath operations (#3343)
Browse files Browse the repository at this point in the history
for some reason, safediv and safemul were switched
  • Loading branch information
charles-cooper authored Apr 7, 2023
1 parent 62d2cfa commit 11a78eb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions vyper/codegen/arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def safe_mul(x, y):
# (if bits == 256, clamp_basetype is a no-op)
res = clamp_basetype(res)

check = IRnode.from_list(["assert", ok], error_msg="safediv")
check = IRnode.from_list(["assert", ok], error_msg="safemul")
res = IRnode.from_list(["seq", check, res], typ=res.typ)

return b1.resolve(res)
Expand Down Expand Up @@ -333,15 +333,15 @@ def safe_div(x, y):
# TODO maybe use safe_mul
res = clamp_basetype(res)

check = IRnode.from_list(["assert", ok], error_msg="safemul")
check = IRnode.from_list(["assert", ok], error_msg="safediv")
return IRnode.from_list(b1.resolve(["seq", check, res]))


# def safe_mod(x: IRnode, y: IRnode) -> IRnode:
def safe_mod(x, y):
typ = x.typ
MOD = "smod" if typ.is_signed else "mod"
return IRnode.from_list([MOD, x, clamp("gt", y, 0)])
return IRnode.from_list([MOD, x, clamp("gt", y, 0)], error_msg="safemod")


# def safe_pow(x: IRnode, y: IRnode) -> IRnode:
Expand Down

0 comments on commit 11a78eb

Please sign in to comment.