Skip to content

Commit 9c98997

Browse files
committed
[utils] fix off-by-one line number bug
When folding up lines of nested expansions, the line number would be off by 1, which would lead to lines being shuffled around.
1 parent b99945f commit 9c98997

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ func foo(_ x: Int) {
132132
}
133133
""")
134134
//expected-expansion@+5:14{{
135-
// expected-error@3 {{cannot find 'b' in scope; did you mean 'x'?}}
136135
// expected-note@1 2{{'x' declared here}}
137136
// expected-error@2 {{cannot find 'a' in scope; did you mean 'x'?}}
137+
// expected-error@3 {{cannot find 'b' in scope; did you mean 'x'?}}
138138
//}}
139139
func foo() {}
140140

utils/update_verify_tests/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ def parse_diag(line, filename, prefix):
262262

263263

264264
def add_line(new_line, lines):
265+
assert new_line.line_n > 0
265266
lines.insert(new_line.line_n - 1, new_line)
266267
for i in range(new_line.line_n, len(lines)):
267268
line = lines[i]
@@ -429,7 +430,7 @@ def fold_expansions(lines):
429430
if line.diag.category == "closing":
430431
line.diag.parent.closer = line
431432
else:
432-
line.line_n = len(line.diag.parent.nested_lines)
433+
line.line_n = len(line.diag.parent.nested_lines) + 1
433434
add_line(line, line.diag.parent.nested_lines)
434435

435436

0 commit comments

Comments
 (0)