Commit abd1bc8
fix(compiler): correct spans when parsing bindings with comments (#44785)
The previous fix for correcting spans with comments in
59eef29
had the unfortunate side effect of _breaking_ the spans with comments
when there was leading whitespace. This happened because the previous
fix was testing one without a comment, identifying that the offset shouldn't
have anything added to it, and then removing that offset adjustment
(`offsets[i] + (expressionText.length - sourceToLex.length)`).
Upon further investigation, this offset adjustment _was actually
necessary_ for when the input had comments, but this was only because
the `stripComments` function used `trim` to remove whitespace for these
cases. This is the real problem -- not only does it create a ton of confusion
but also it means that the behavior of the lexer and resulting spans is
different between inputs with comments and inputs without comments.
After reviewing how the `inputLength` of `_ParseAST` was used, it
appears that the correct behavior would be to _not_ trim the input. The
`inputLength` is used to advance the current index beyond points which
have been processed. This _should_ include any whitespace. Additionally,
`inputLength` doesn't appear to be needed at all. When there was no
comment in the input, it was always equal to the `input.length` anyways.
When there _is_ a comment, it should include that comment anyways to
advance the index beyond the comment.
PR Close #447851 parent 7316e72 commit abd1bc8
File tree
3 files changed
+38
-18
lines changed- packages
- compiler-cli/src/ngtsc/indexer/test
- compiler
- src/expression_parser
- test/render3
3 files changed
+38
-18
lines changedLines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
65 | 78 | | |
66 | 79 | | |
67 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
46 | | - | |
| 44 | + | |
47 | 45 | | |
48 | 46 | | |
49 | 47 | | |
| |||
90 | 88 | | |
91 | 89 | | |
92 | 90 | | |
93 | | - | |
94 | | - | |
| 91 | + | |
95 | 92 | | |
96 | 93 | | |
97 | 94 | | |
| |||
138 | 135 | | |
139 | 136 | | |
140 | 137 | | |
141 | | - | |
142 | | - | |
| 138 | + | |
| 139 | + | |
143 | 140 | | |
144 | 141 | | |
145 | 142 | | |
| |||
159 | 156 | | |
160 | 157 | | |
161 | 158 | | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
166 | 162 | | |
167 | 163 | | |
168 | 164 | | |
| |||
180 | 176 | | |
181 | 177 | | |
182 | 178 | | |
183 | | - | |
| 179 | + | |
184 | 180 | | |
185 | 181 | | |
186 | 182 | | |
| |||
275 | 271 | | |
276 | 272 | | |
277 | 273 | | |
278 | | - | |
| 274 | + | |
279 | 275 | | |
280 | 276 | | |
281 | 277 | | |
| |||
392 | 388 | | |
393 | 389 | | |
394 | 390 | | |
395 | | - | |
396 | | - | |
| 391 | + | |
| 392 | + | |
397 | 393 | | |
398 | 394 | | |
399 | 395 | | |
| |||
429 | 425 | | |
430 | 426 | | |
431 | 427 | | |
432 | | - | |
| 428 | + | |
433 | 429 | | |
434 | 430 | | |
435 | 431 | | |
| |||
587 | 583 | | |
588 | 584 | | |
589 | 585 | | |
590 | | - | |
| 586 | + | |
591 | 587 | | |
592 | 588 | | |
593 | 589 | | |
| |||
623 | 619 | | |
624 | 620 | | |
625 | 621 | | |
626 | | - | |
| 622 | + | |
627 | 623 | | |
628 | 624 | | |
629 | 625 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
20 | 31 | | |
21 | 32 | | |
22 | 33 | | |
| |||
0 commit comments