Skip to content

Commit

Permalink
refactor[ux]: remove deprecated VyperNode properties (#3999)
Browse files Browse the repository at this point in the history
This commit removes the `n` property from `Num` vyper node and the `s`
property from `Str` vyper node as they have been deprecated in the
python AST (and it is clearer to use the `value` property anyways)
  • Loading branch information
tserg committed May 7, 2024
1 parent ef2d535 commit 6d4c09c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
10 changes: 0 additions & 10 deletions vyper/ast/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,11 +788,6 @@ class Num(Constant):
# inherited class for all numeric constant node types
__slots__ = ()

@property
def n(self):
# TODO phase out use of Num.n and remove this
return self.value

def validate(self):
if self.value < SizeLimits.MIN_INT256:
raise OverflowException("Value is below lower bound for all numeric types", self)
Expand Down Expand Up @@ -894,11 +889,6 @@ def validate(self):
if ord(c) >= 256:
raise InvalidLiteral(f"'{c}' is not an allowed string literal character", self)

@property
def s(self):
# TODO phase out use of Str.s and remove this
return self.value


class Bytes(Constant):
__slots__ = ()
Expand Down
8 changes: 4 additions & 4 deletions vyper/codegen/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(self, node, context, is_stmt=False):

def parse_Int(self):
typ = self.expr._metadata["type"]
return IRnode.from_list(self.expr.n, typ=typ)
return IRnode.from_list(self.expr.value, typ=typ)

def parse_Decimal(self):
val = self.expr.value * DECIMAL_DIVISOR
Expand Down Expand Up @@ -133,8 +133,8 @@ def parse_Str(self):

# Byte literals
def parse_Bytes(self):
bytez = self.expr.s
bytez_length = len(self.expr.s)
bytez = self.expr.value
bytez_length = len(self.expr.value)
typ = BytesT(bytez_length)
return self._make_bytelike(typ, bytez, bytez_length)

Expand Down Expand Up @@ -345,7 +345,7 @@ def parse_Subscript(self):
elif is_tuple_like(sub.typ):
# should we annotate expr.slice in the frontend with the
# folded value instead of calling reduced() here?
index = self.expr.slice.reduced().n
index = self.expr.slice.reduced().value
# note: this check should also happen in get_element_ptr
if not 0 <= index < len(sub.typ.member_types):
raise TypeCheckFailure("unreachable")
Expand Down

0 comments on commit 6d4c09c

Please sign in to comment.