forked from M-Labs/artiq
1
0
Fork 0

transforms.asttyped_rewriter: fix class redefinition diagnostic.

This commit is contained in:
whitequark 2015-11-17 01:17:25 +03:00
parent 80f0bfe0ad
commit b0c6b70971
2 changed files with 7 additions and 1 deletions

View File

@ -263,7 +263,7 @@ class ASTTypedRewriter(algorithm.Transformer):
if node.name in self.env_stack[-1]: if node.name in self.env_stack[-1]:
diag = diagnostic.Diagnostic("fatal", diag = diagnostic.Diagnostic("fatal",
"variable '{name}' is already defined", {"name":name}, loc) "variable '{name}' is already defined", {"name":node.name}, node.name_loc)
self.engine.process(diag) self.engine.process(diag)
extractor = LocalExtractor(env_stack=self.env_stack, engine=self.engine) extractor = LocalExtractor(env_stack=self.env_stack, engine=self.engine)

View File

@ -8,3 +8,9 @@ class a(1):
class b: class b:
# CHECK-L: ${LINE:+1}: fatal: class body must contain only assignments and function definitions # CHECK-L: ${LINE:+1}: fatal: class body must contain only assignments and function definitions
x += 1 x += 1
class c:
pass
# CHECK-L: ${LINE:+1}: fatal: variable 'c' is already defined
class c:
pass