fix(compiler): infinite loop in parser assignment expression with invalid left-hand expression#47151
fix(compiler): infinite loop in parser assignment expression with invalid left-hand expression#47151crisbeto wants to merge 1 commit intoangular:mainfrom
Conversation
…alid left-hand expression In angular#39004 some logic was introduced that tries to recover invalid expressions by treating the `=` token as a recovery point. It works by skipping ahead to the next recovery point inside the `skip` method which is called whenever an error is reported. This can lead to an infinite loop inside the `parseChain` method which assumes that reporting an error would've skipped over the token, but that won't happen since the `=` token is a recovery point. These changes resolve the infinite loop by breaking the loop if `error` didn't skip to a different token after the error was reported. Fixes angular#47131.
| // lead to an infinite loop. If that's the case, break the loop assuming that we can't | ||
| // parse further. | ||
| if (this.index === errorIndex) { | ||
| break; |
There was a problem hiding this comment.
I was on the fence between breaking the loop here and calling advance which would attempt to continue parsing. I went with this, because the example from the unit test would turn from (a[1] = b) = c = d into a[1] = b; c; d which didn't seem very useful. I don't feel strongly one way or the other so I'm open to changing it.
JoostK
left a comment
There was a problem hiding this comment.
LGTM
This comment was marked as outdated.
This comment was marked as outdated.
|
This PR was merged into the repository by commit dc52cef. |
…alid left-hand expression (#47151) In #39004 some logic was introduced that tries to recover invalid expressions by treating the `=` token as a recovery point. It works by skipping ahead to the next recovery point inside the `skip` method which is called whenever an error is reported. This can lead to an infinite loop inside the `parseChain` method which assumes that reporting an error would've skipped over the token, but that won't happen since the `=` token is a recovery point. These changes resolve the infinite loop by breaking the loop if `error` didn't skip to a different token after the error was reported. Fixes #47131. PR Close #47151
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@angular/animations](https://github.com/angular/angular) | dependencies | patch | [`14.1.2` -> `14.1.3`](https://renovatebot.com/diffs/npm/@angular%2fanimations/14.1.2/14.1.3) | | [@angular/common](https://github.com/angular/angular) | dependencies | patch | [`14.1.2` -> `14.1.3`](https://renovatebot.com/diffs/npm/@angular%2fcommon/14.1.2/14.1.3) | | [@angular/compiler](https://github.com/angular/angular) | dependencies | patch | [`14.1.2` -> `14.1.3`](https://renovatebot.com/diffs/npm/@angular%2fcompiler/14.1.2/14.1.3) | | [@angular/compiler-cli](https://github.com/angular/angular) | devDependencies | patch | [`14.1.2` -> `14.1.3`](https://renovatebot.com/diffs/npm/@angular%2fcompiler-cli/14.1.2/14.1.3) | | [@angular/core](https://github.com/angular/angular) | dependencies | patch | [`14.1.2` -> `14.1.3`](https://renovatebot.com/diffs/npm/@angular%2fcore/14.1.2/14.1.3) | | [@angular/forms](https://github.com/angular/angular) | dependencies | patch | [`14.1.2` -> `14.1.3`](https://renovatebot.com/diffs/npm/@angular%2fforms/14.1.2/14.1.3) | | [@angular/platform-browser](https://github.com/angular/angular) | dependencies | patch | [`14.1.2` -> `14.1.3`](https://renovatebot.com/diffs/npm/@angular%2fplatform-browser/14.1.2/14.1.3) | | [@angular/platform-browser-dynamic](https://github.com/angular/angular) | dependencies | patch | [`14.1.2` -> `14.1.3`](https://renovatebot.com/diffs/npm/@angular%2fplatform-browser-dynamic/14.1.2/14.1.3) | --- ### Release Notes <details> <summary>angular/angular</summary> ### [`v14.1.3`](https://github.com/angular/angular/blob/HEAD/CHANGELOG.md#​1413-2022-08-17) [Compare Source](angular/angular@14.1.2...14.1.3) ##### compiler | Commit | Type | Description | | -- | -- | -- | | [0583227708](angular/angular@0583227) | fix | infinite loop in parser assignment expression with invalid left-hand expression ([#​47151](angular/angular#47151)) | #### Special Thanks AlirezaEbrahimkhani, Alma Eyre, Andrew Scott, Bob Watson, George Kalpakas, Kalbarczyk, Kristiyan Kostadinov, Leosvel Pérez Espinosa, Roman Matusevich and Sonu Kapoor <!-- CHANGELOG SPLIT MARKER --> </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xNjEuMCIsInVwZGF0ZWRJblZlciI6IjMyLjE2MS4wIn0=--> Co-authored-by: cabr2-bot <cabr2.help@gmail.com> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1512 Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org> Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org> Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
In #39004 some logic was introduced that tries to recover invalid expressions by treating the
=token as a recovery point. It works by skipping ahead to the next recovery point inside theskipmethod which is called whenever an error is reported. This can lead to an infinite loop inside theparseChainmethod which assumes that reporting an error would've skipped over the token, but that won't happen since the=token is a recovery point. These changes resolve the infinite loop by breaking the loop iferrordidn't skip to a different token after the error was reported.Fixes #47131.