Skip to content

Commit 4af20b2

Browse files
committed
[utils] fix bug in diagnostic stealing logic
When replacing expected diagnostic content, we should consider expected diagnostics targeting the same target, not targeting the line the expected diagnostic is on.
1 parent 3eb1bea commit 4af20b2

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
4+
// RUN: not %target-swift-frontend-verify -typecheck %t/test.swift 2>%t/output.txt
5+
// RUN: %update-verify-tests < %t/output.txt
6+
// RUN: %target-swift-frontend-verify -typecheck %t/test.swift
7+
// RUN: %diff %t/test.swift %t/test.swift.expected
8+
9+
//--- test.swift
10+
func foo() {
11+
let a = 2 // expected-error@+1{{asdf}}
12+
b = a // expected-error@+1{{asdf}}
13+
}
14+
15+
func bar() {
16+
a = 2 // expected-error@+1{{asdf}}
17+
}
18+
19+
//--- test.swift.expected
20+
func foo() {
21+
// expected-note@+1{{'a' declared here}}
22+
let a = 2 // expected-error@+1{{cannot find 'b' in scope; did you mean 'a'?}}
23+
b = a
24+
}
25+
26+
func bar() {
27+
// expected-error@+1{{cannot find 'a' in scope}}
28+
a = 2
29+
}
30+

utils/update_verify_tests/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def remove_dead_diags(lines):
398398
remove_line(line, lines)
399399
else:
400400
assert line.diag.is_from_source_file
401-
for other_diag in line.targeting_diags:
401+
for other_diag in line.diag.target.targeting_diags:
402402
if (
403403
other_diag.is_from_source_file
404404
or other_diag.count == 0

0 commit comments

Comments
 (0)