summaryrefslogtreecommitdiff
path: root/mesonbuild/interpreterbase/interpreterbase.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2024-11-01 10:45:12 -0700
committerDylan Baker <dylan@pnwbakers.com>2024-11-15 11:32:50 -0800
commit929df93ba80be347bea5df850ebce280aed64be7 (patch)
treefa783dd5425b47a38c789c9339a797ac0e172e6a /mesonbuild/interpreterbase/interpreterbase.py
parentb3f9b9dc06fcd6c0a3070380b42e0ab5fd6c1226 (diff)
downloadmeson-929df93ba80be347bea5df850ebce280aed64be7.tar.gz
interpreter: remove current_lineno
This was only used in a couple of places, and requires extra tracking to ensure it is correct, while we already have `current_node.lineno`, which is always accurate and up to date. I have also fixed a potential strict-null issue by using a sentinel node for `current_node`
Diffstat (limited to 'mesonbuild/interpreterbase/interpreterbase.py')
-rw-r--r--mesonbuild/interpreterbase/interpreterbase.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/mesonbuild/interpreterbase/interpreterbase.py b/mesonbuild/interpreterbase/interpreterbase.py
index 525d5d6c5..5f9df4cb5 100644
--- a/mesonbuild/interpreterbase/interpreterbase.py
+++ b/mesonbuild/interpreterbase/interpreterbase.py
@@ -82,7 +82,7 @@ class InterpreterBase:
self.current_lineno = -1
# Current node set during a function call. This can be used as location
# when printing a warning message during a method call.
- self.current_node: mparser.BaseNode = None
+ self.current_node = mparser.BaseNode(-1, -1, 'sentinel')
# This is set to `version_string` when this statement is evaluated:
# meson.version().compare_version(version_string)
# If it was part of a if-clause, it is used to temporally override the
@@ -183,7 +183,6 @@ class InterpreterBase:
while i < len(statements):
cur = statements[i]
try:
- self.current_lineno = cur.lineno
self.evaluate_statement(cur)
except Exception as e:
if getattr(e, 'lineno', None) is None: