From b3d9f2053b2e60d8a0fa04f01e496dd64cc2406b Mon Sep 17 00:00:00 2001 From: tserg <8017125+tserg@users.noreply.github.com> Date: Fri, 29 Dec 2023 16:04:57 +0800 Subject: [PATCH] remove _is_prefoldable --- vyper/ast/nodes.py | 9 --------- vyper/semantics/analysis/pre_typecheck.py | 13 ++++++------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/vyper/ast/nodes.py b/vyper/ast/nodes.py index 5712cb8f2b..209816247e 100644 --- a/vyper/ast/nodes.py +++ b/vyper/ast/nodes.py @@ -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 @@ -924,7 +922,6 @@ def s(self): class List(ExprNode): __slots__ = ("elements",) - _is_prefoldable = True _translated_fields = {"elts": "elements"} @property @@ -938,7 +935,6 @@ def fold(self) -> Optional[ExprNode]: class Tuple(ExprNode): __slots__ = ("elements",) - _is_prefoldable = True _translated_fields = {"elts": "elements"} @property @@ -972,7 +968,6 @@ class Name(ExprNode): class UnaryOp(ExprNode): __slots__ = ("op", "operand") - _is_prefoldable = True def fold(self) -> ExprNode: """ @@ -1022,7 +1017,6 @@ def _op(self, value): class BinOp(ExprNode): __slots__ = ("left", "op", "right") - _is_prefoldable = True def fold(self) -> ExprNode: """ @@ -1172,7 +1166,6 @@ class RShift(Operator): class BoolOp(ExprNode): __slots__ = ("op", "values") - _is_prefoldable = True def fold(self) -> ExprNode: """ @@ -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: @@ -1331,7 +1323,6 @@ class Attribute(ExprNode): class Subscript(ExprNode): __slots__ = ("slice", "value") - _is_prefoldable = True def fold(self) -> ExprNode: """ diff --git a/vyper/semantics/analysis/pre_typecheck.py b/vyper/semantics/analysis/pre_typecheck.py index a846f354ff..b0e900a76c 100644 --- a/vyper/semantics/analysis/pre_typecheck.py +++ b/vyper/semantics/analysis/pre_typecheck.py @@ -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