Skip to content

Commit e54214c

Browse files
committed
Add test case: test_error_message_without_previous_definition_location
1 parent 8b72ce8 commit e54214c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/python/tir-analysis/test_tir_analysis_verify_well_formed.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,5 +345,32 @@ def func():
345345
tvm.tir.analysis.verify_well_formed(mod)
346346

347347

348+
def test_error_message_without_previous_definition_location():
349+
"""Test case 1: Error message without 'It was first defined at'
350+
351+
This tests the scenario where it == end(), so the error message should contain
352+
'TIR is ill-formed, due to multiple definitions of variable' but should NOT
353+
contain 'It was first defined at' since the iterator is invalid.
354+
"""
355+
356+
@I.ir_module(check_well_formed=False)
357+
def func_variable_not_in_previous_map():
358+
x = T.int32()
359+
360+
with T.LetStmt(42, var=x):
361+
T.evaluate(x)
362+
363+
with T.LetStmt(99, var=x): # This should trigger the error
364+
T.evaluate(x)
365+
366+
with pytest.raises(ValueError) as exc_info:
367+
tvm.tir.analysis.verify_well_formed(func_variable_not_in_previous_map, assert_mode=True)
368+
369+
error_msg = str(exc_info.value)
370+
371+
assert "TIR is ill-formed" in error_msg
372+
assert "multiple definitions of variable" in error_msg
373+
374+
348375
if __name__ == "__main__":
349376
tvm.testing.main()

0 commit comments

Comments
 (0)