Fixing variable name not showing when error

This commit is contained in:
Anthony Debucquoy 2025-03-20 21:36:13 +01:00
parent 1a181095c6
commit 312f4cd125
Signed by: tonitch
GPG Key ID: A78D6421F083D42E

View File

@ -49,19 +49,19 @@ class Variables:
self.trace = trace
def get(self, name):
assert name in self.variables, "la variable {name} n'éxiste pas"
assert name in self.variables, f"la variable {name} n'éxiste pas"
if self.trace:
print(f"{trace_format}accède {name}{reset_format}", file=sys.stderr)
return self.variables[name].value
def declare(self, typ, name, value=None):
assert name not in self.variables, "la variable {name} existe déjà"
assert name not in self.variables, f"la variable {name} existe déjà"
self.variables[name] = self.Variable(typ, value)
if self.trace:
print(f"{trace_format}déclare {name} = {value}{reset_format}", file=sys.stderr)
def assign(self, name, value):
assert name in self.variables, "la variable n'éxiste pas"
assert name in self.variables, f"la variable n'éxiste pas"
self.variables[name].set(value)
if self.trace:
print(f"{trace_format}modifie {name} = {value}{reset_format}", file=sys.stderr)