Skip to content

Commit 375ad43

Browse files
authored
[mypyc] Internal: use emojis to highlight IR errors in tests (#20684)
The errors were a bit non-obvious in long IR dumps.
1 parent 7029712 commit 375ad43

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

mypyc/ir/pprint.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ def format_blocks(
414414
lines.append("L%d:%s" % (block.label, handler_msg))
415415
if block in source_to_error:
416416
for error in source_to_error[block]:
417-
lines.append(f" ERR: {error}")
417+
lines.append(f" ERROR: {error}")
418418
ops = block.ops
419419
if (
420420
isinstance(ops[-1], Goto)
@@ -429,8 +429,11 @@ def format_blocks(
429429
line = " " + op.accept(visitor)
430430
lines.append(line)
431431
if op in source_to_error:
432+
first = len(lines) - 1
433+
# Use emojis to highlight the error
432434
for error in source_to_error[op]:
433-
lines.append(f" ERR: {error}")
435+
lines.append(f" \U0001f446 ERROR: {error}")
436+
lines[first] = " \U0000274c " + lines[first][4:]
434437

435438
if not isinstance(block.ops[-1], (Goto, Branch, Return, Unreachable)):
436439
# Each basic block needs to exit somewhere.

mypyc/test/test_ircheck.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ def test_pprint(self) -> None:
178178
assert formatted == [
179179
"def func_1():",
180180
"L0:",
181-
" goto L1",
182-
" ERR: Invalid control operation target: 1",
181+
" \U0000274c goto L1",
182+
" \U0001f446 ERROR: Invalid control operation target: 1",
183183
]
184184

185185
def test_load_address_declares_register(self) -> None:

0 commit comments

Comments
 (0)