fixing it and supporting base of zero

pull/608/head
Claudia Richoux 4 years ago
parent 246a4baa0e
commit d06c397a5c
  1. 20
      slither/slithir/variables/constant.py

@ -25,18 +25,16 @@ class Constant(SlithIRVariable):
if val.startswith('0x') or val.startswith('0X'): if val.startswith('0x') or val.startswith('0X'):
self._val = int(val, 16) self._val = int(val, 16)
else: else:
if 'e' in val: if 'e' in val or 'E' in val:
base, expo = val.split('e') base, expo = val.split('e') if 'e' in val else val.split('E')
expo = int(expo) base, expo = Decimal(base), int(expo)
if expo > 80: if expo > 80:
raise ValueError("exponent is too large to fit in any Solidity integer size") if base != Decimal(0):
self._val = int(Decimal(base) * (10 ** expo)) raise ValueError("exponent is too large to fit in any Solidity integer size")
elif 'E' in val: else:
base, expo = val.split('E') self._val = 0
expo = int(expo) else:
if expo > 80: self._val = int(Decimal(base) * (10 ** expo))
raise ValueError("exponent is too large to fit in any Solidity integer size")
self._val = int(Decimal(base) * (10 ** expo))
else: else:
self._val = int(Decimal(val)) self._val = int(Decimal(val))
elif type.type == 'bool': elif type.type == 'bool':

Loading…
Cancel
Save