forked from M-Labs/artiq
transforms.asttyped_rewriter: fix class redefinition diagnostic.
This commit is contained in:
parent
80f0bfe0ad
commit
b0c6b70971
|
@ -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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue