semantic: warn on variable shadowing
This commit is contained in:
parent
1bf549eda4
commit
714c9b490e
1 changed files with 5 additions and 0 deletions
|
|
@ -131,6 +131,11 @@ class Context:
|
|||
if name in self.variables:
|
||||
raise SemanticAnalysisError(value.location())
|
||||
|
||||
upper_definition = self._get_symbol("variables", name)
|
||||
if upper_definition is not None:
|
||||
CompilationWarning(definition.location(),
|
||||
f"Shadowing previous definition {upper_definition.definition.location()}").raise_warning()
|
||||
|
||||
typedef = self.get_type(type_identifier.value)
|
||||
if typedef is None:
|
||||
raise SemanticAnalysisError(location=type_identifier.location(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue