Skip to content

Commit

Permalink
Improve CHECK-LABEL error message (#26)
Browse files Browse the repository at this point in the history
I was debugging a CHECK-LABEL related problem and struggled because I
was trying to fix the wrong label in my file. This improved error
message should help in those situations.
  • Loading branch information
Moxinilian authored Jul 20, 2024
1 parent 07065bb commit ba7820b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion filecheck/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def preprocess_label(self, op: CheckOp):
pattern, _ = compile_uops(op, dict(), self.opts)
match = self.input.find_between(pattern, self.range)
if not match:
raise CheckError(f"{op.check_name}: Could not find label in input", op)
raise CheckError(
f"{op.check_name}: Could not find label '{op.arg}' in input", op
)

self.range = self.range.split_at(match)
self.input.ranges.append(self.range)
16 changes: 16 additions & 0 deletions tests/filecheck/diagnostics/label-error.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// RUN: strip-comments.sh %s | exfail filecheck %s --comment-prefixes=RUN,COM,DIAG | filecheck %s --check-prefix=DIAG

hello:
a
b

world:
c
d

// CHECK-LABEL: hello
// CHECK-NOT: d
// CHECK-LABEL: woupsrld
// CHECK: d

// DIAG: Could not find label 'woupsrld' in input

0 comments on commit ba7820b

Please sign in to comment.