Skip to content

Commit bf46369

Browse files
committed
[utils] only use column for comparison when emitted
This fixes a bug that was introduced where two diagnostics on the same line, with the same content, would be emitted separately if they occurred on separate columns. This despite the fact that neither of these checks specify the column when emitted. The checks are now properly merged again.
1 parent d71c8cc commit bf46369

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

utils/update_verify_tests/core.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def __init__(
8282
self.absolute_target()
8383
self.whitespace_strings = whitespace_strings
8484
self.is_from_source_file = is_from_source_file
85-
self.col = col
85+
self._col = col
8686
self.nested_lines = nested_lines
8787
self.parent = None
8888
self.closer = None
@@ -116,6 +116,12 @@ def absolute_target(self):
116116
def relative_target(self):
117117
return self.absolute_target() - self.line.line_n
118118

119+
def col(self):
120+
# expected-expansion requires column. Otherwise only retain column info if it's already there.
121+
if self._col and (self.category == "expansion" or self.is_from_source_file):
122+
return self._col
123+
return None
124+
119125
def take(self, other_diag):
120126
assert self.count == 0
121127
assert other_diag.count > 0
@@ -159,11 +165,7 @@ def render(self):
159165
standard single space, let it be to avoid disrupting manual formatting.
160166
"""
161167
whitespace2_s = ""
162-
col_s = (
163-
f":{self.col}"
164-
if self.col and (self.category == "expansion" or self.is_from_source_file)
165-
else ""
166-
)
168+
col_s = f":{self.col()}" if self.col() else ""
167169
base_s = f"//{whitespace1_s}expected-{self.prefix}{self.category}{re_s}{line_location_s}{col_s}{whitespace2_s}{count_s}"
168170
if self.category == "expansion":
169171
return base_s + "{{"
@@ -438,7 +440,7 @@ def expand_expansions(lines):
438440

439441

440442
def error_refers_to_diag(diag_error, diag, target_line_n):
441-
if diag_error.col and diag.col and diag_error.col != diag.col:
443+
if diag_error.col and diag.col() and diag_error.col != diag.col():
442444
return False
443445
return (
444446
target_line_n == diag.absolute_target()

0 commit comments

Comments
 (0)