Skip to content

Commit

Permalink
remove _is_prefoldable
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Dec 29, 2023
1 parent 4130dbb commit b3d9f20
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
9 changes: 0 additions & 9 deletions vyper/ast/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,6 @@ class VyperNode:
_description : str, optional
A human-readable description of the node. Used to give more verbose error
messages.
_is_prefoldable : str, optional
If `True`, indicates that pre-folding should be attempted on the node.
_only_empty_fields : Tuple, optional
Field names that, if present, must be set to None or a `SyntaxException`
is raised. This attribute is used to exclude syntax that is valid in Python
Expand Down Expand Up @@ -924,7 +922,6 @@ def s(self):

class List(ExprNode):
__slots__ = ("elements",)
_is_prefoldable = True
_translated_fields = {"elts": "elements"}

@property
Expand All @@ -938,7 +935,6 @@ def fold(self) -> Optional[ExprNode]:

class Tuple(ExprNode):
__slots__ = ("elements",)
_is_prefoldable = True
_translated_fields = {"elts": "elements"}

@property
Expand Down Expand Up @@ -972,7 +968,6 @@ class Name(ExprNode):

class UnaryOp(ExprNode):
__slots__ = ("op", "operand")
_is_prefoldable = True

def fold(self) -> ExprNode:
"""
Expand Down Expand Up @@ -1022,7 +1017,6 @@ def _op(self, value):

class BinOp(ExprNode):
__slots__ = ("left", "op", "right")
_is_prefoldable = True

def fold(self) -> ExprNode:
"""
Expand Down Expand Up @@ -1172,7 +1166,6 @@ class RShift(Operator):

class BoolOp(ExprNode):
__slots__ = ("op", "values")
_is_prefoldable = True

def fold(self) -> ExprNode:
"""
Expand Down Expand Up @@ -1220,7 +1213,6 @@ class Compare(ExprNode):
"""

__slots__ = ("left", "op", "right")
_is_prefoldable = True

def __init__(self, *args, **kwargs):
if len(kwargs["ops"]) > 1 or len(kwargs["comparators"]) > 1:
Expand Down Expand Up @@ -1331,7 +1323,6 @@ class Attribute(ExprNode):

class Subscript(ExprNode):
__slots__ = ("slice", "value")
_is_prefoldable = True

def fold(self) -> ExprNode:
"""
Expand Down
13 changes: 6 additions & 7 deletions vyper/semantics/analysis/pre_typecheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,9 @@ def prefold(node: vy_ast.VyperNode, constants: dict[str, vy_ast.VyperNode]):
except UnfoldableNode:
pass

if getattr(node, "_is_prefoldable", None):
# call `get_folded_value` for its side effects and allow all
# exceptions other than `UnfoldableNode` to raise
try:
node.get_folded_value()
except UnfoldableNode:
pass
# call `get_folded_value` for its side effects and allow all
# exceptions other than `UnfoldableNode` to raise
try:
node.get_folded_value()
except UnfoldableNode:
pass

0 comments on commit b3d9f20

Please sign in to comment.