semantic: make unused variables print a warning instead of raising an error

This commit is contained in:
Antoine Viallon 2024-01-10 23:58:29 +01:00
parent fcf0b9c12d
commit 76cdfc0b5f
Signed by: aviallon
GPG key ID: 186FC35EDEB25716

View file

@ -229,8 +229,8 @@ class Context:
# Check for unused variables # Check for unused variables
if len(variable.reads) == 0 and variable.definition is not None: if len(variable.reads) == 0 and variable.definition is not None:
raise SemanticAnalysisError(variable.definition.location(), CompilationWarning(variable.definition.location(),
message=f"Variable '{variable.name}' is unused") message=f"Variable '{variable.name}' is unused").raise_warning()
for context in self.child_contexts.values(): for context in self.child_contexts.values():
context.check() context.check()