EmitterWriter::get_max_line_num
works incorrectly
#64447
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
TL;DR:
EmitterWriter::get_max_line_num
unconditionally returnsself.get_multispan_max_line_num(span)
no matter what is contained inchildren
.Longer explanation: let's take a look at the code of method (it's rather short):
Here
self.get_multispan_max_line_num(span)
returns a plainusize
. Firstly, since0
is the smallest possible value ofusize
, the first three lines can be rewritten without changing the meaning asSo after executing these lines
max == primary
. Secondly, in the loopif
comparessub_result
withmax
but assigns eithermax
orprimary
. Ifmax == primary
in the beginning of iteration, then this also holds in the end of iteration. Since this preposition holds before executing the loop, it also holds after executing the loop, so the whole method just returnsprimary
, QED.Erroneous code was introduced in 71ec286.
Unfortunately, I'm not familliar enough with the code to propose the correct fix.
The text was updated successfully, but these errors were encountered: