Skip to content

Commit 5b22c60

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

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/python/tir-analysis/test_tir_analysis_verify_well_formed.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,5 +345,35 @@ 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+
364+
with T.LetStmt(99, var=x): # This should trigger the error
365+
T.evaluate(x)
366+
367+
368+
with pytest.raises(ValueError) as exc_info:
369+
tvm.tir.analysis.verify_well_formed(func_variable_not_in_previous_map, assert_mode=True)
370+
371+
372+
error_msg = str(exc_info.value)
373+
374+
assert "TIR is ill-formed" in error_msg
375+
assert "multiple definitions of variable" in error_msg
376+
377+
348378
if __name__ == "__main__":
349379
tvm.testing.main()

0 commit comments

Comments
 (0)