Skip to content

Commit 4d5844b

Browse files
committed
[utils] only steal 1 diagnostic
This fixes a bug in the diagnostic stealing logic when multiple diagnostics target the same line, which would trigger an assert.
1 parent 4af20b2 commit 4d5844b

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

test/Utils/update-verify-tests/update-existing.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ func bar() {
1616
a = 2 // expected-error@+1{{asdf}}
1717
}
1818

19+
func baz() {
20+
// expected-error@+2{{cannot find 'a' in scope}}
21+
// expected-error@+1{{cannot find 'a'}}
22+
let b = a; let c = a; // expected-error{{asdf}}
23+
}
24+
25+
func qux() {
26+
let b = a; let c = a; // expected-error{{asdf}}
27+
}
28+
29+
func foobar() {
30+
var b = 1
31+
b = a; b = a; // expected-error{{asdf}}
32+
}
33+
1934
//--- test.swift.expected
2035
func foo() {
2136
// expected-note@+1{{'a' declared here}}
@@ -28,3 +43,22 @@ func bar() {
2843
a = 2
2944
}
3045

46+
func baz() {
47+
// expected-error@+3{{cannot find 'a' in scope}}
48+
// expected-error@+2{{cannot find 'a'}}
49+
// expected-note@+1{{'b' declared here}}
50+
let b = a; let c = a;
51+
}
52+
53+
func qux() {
54+
// expected-note@+2{{'b' declared here}}
55+
// expected-error@+1{{cannot find 'a' in scope}}
56+
let b = a; let c = a; // expected-error{{cannot find 'a' in scope; did you mean 'b'?}}
57+
}
58+
59+
func foobar() {
60+
// expected-note@+1 2{{'b' declared here}}
61+
var b = 1
62+
b = a; b = a; // expected-error 2{{cannot find 'a' in scope; did you mean 'b'?}}
63+
}
64+

utils/update_verify_tests/core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ def remove_dead_diags(lines):
409409
continue
410410
line.diag.take(other_diag)
411411
remove_line(other_diag.line, lines)
412+
break
412413

413414

414415
def fold_expansions(lines):

0 commit comments

Comments
 (0)