From e26bd9c11947677080a1ed283f758de4eb847a7d Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Mon, 18 Nov 2024 22:03:18 +0100 Subject: [PATCH] remove the weird parent thing --- vyper/ast/parse.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/vyper/ast/parse.py b/vyper/ast/parse.py index 20cc483a63..f83b27a6e3 100644 --- a/vyper/ast/parse.py +++ b/vyper/ast/parse.py @@ -206,17 +206,15 @@ def generic_visit(self, node): for s in ("lineno", "end_lineno", "col_offset", "end_col_offset"): # ensure fields exist - if (val := getattr(node, s, None)) is None and self._parent is not None: - val = getattr(self._parent, s) - setattr(node, s, val) + setattr(node, s, getattr(node, s, None)) - self._parent = node + if node.col_offset is not None: + adj = adjustments.get((node.lineno, node.col_offset), 0) + node.col_offset += adj - adj = adjustments.get((node.lineno, node.col_offset), 0) - node.col_offset += adj - - adj = adjustments.get((node.end_lineno, node.end_col_offset), 0) - node.end_col_offset += adj + if node.end_col_offset is not None: + adj = adjustments.get((node.end_lineno, node.end_col_offset), 0) + node.end_col_offset += adj if node.lineno in self.line_offsets and node.end_lineno in self.line_offsets: start_pos = self.line_offsets[node.lineno] + node.col_offset @@ -247,6 +245,7 @@ def _visit_docstring(self, node): return node + def visit_Module(self, node): # TODO: is this the best place for these? maybe they can be on # CompilerData instead. @@ -272,6 +271,12 @@ def visit_ClassDef(self, node): node.ast_type = self._pre_parse_result.modification_offsets[(node.lineno, node.col_offset)] return node + def visit_Load(self, node): + return None + + def visit_Store(self, node): + return None + def visit_For(self, node): """ Visit a For node, splicing in the loop variable annotation provided by