feat(compiler): Recover on malformed keyed reads and keyed writes#39004
feat(compiler): Recover on malformed keyed reads and keyed writes#39004ayazhafiz wants to merge 5 commits intoangular:masterfrom
Conversation
There was a problem hiding this comment.
I think it is okay to keep both errors here, but an argument could be made that they are overlapping. Let me know what you think.
There was a problem hiding this comment.
I feel like it would almost be worth adding these to a separate test(compiler) commit before the changes to the code to make it clear that we were already able to recover from errors in keyed reads and that the changes only affect keyed writes.
There was a problem hiding this comment.
Makes sense, I will do this.
This patch adds support for recovering well-formed (and near-complete) ASTs for semantically malformed keyed reads and keyed writes. See the added tests for details on the types of semantics we can now recover; in particular, notice that some assumptions are made about the form of a keyed read/write intended by a user. For example, in the malformed expression `a[1 + = 2`, we assume that the user meant to write a binary expression for the key of `a`, and assign that key the value `2`. In particular, we now parse this as `a[1 + <empty expression>] = 2`. There are some different interpretations that can be made here, but I think this is reasonable. The actual changes in the parser code are fairly minimal (a nice surprise!); the biggest addition is a `writeContext` that marks whether the `=` operator can serve as a recovery point after error detection. Part of angular#38596
b5cf760 to
c93b550
Compare
|
Caretaker: can you run presubmit? |
…9004) This patch adds support for recovering well-formed (and near-complete) ASTs for semantically malformed keyed reads and keyed writes. See the added tests for details on the types of semantics we can now recover; in particular, notice that some assumptions are made about the form of a keyed read/write intended by a user. For example, in the malformed expression `a[1 + = 2`, we assume that the user meant to write a binary expression for the key of `a`, and assign that key the value `2`. In particular, we now parse this as `a[1 + <empty expression>] = 2`. There are some different interpretations that can be made here, but I think this is reasonable. The actual changes in the parser code are fairly minimal (a nice surprise!); the biggest addition is a `writeContext` that marks whether the `=` operator can serve as a recovery point after error detection. Part of #38596 PR Close #39004
|
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. |
This patch adds support for recovering well-formed (and near-complete)
ASTs for semantically malformed keyed reads and keyed writes. See the
added tests for details on the types of semantics we can now recover;
in particular, notice that some assumptions are made about the form of
a keyed read/write intended by a user. For example, in the malformed
expression
a[1 + = 2, we assume that the user meant to write a binaryexpression for the key of
a, and assign that key the value2. Inparticular, we now parse this as
a[1 + <empty expression>] = 2. Thereare some different interpretations that can be made here, but I think
this is reasonable.
The actual changes in the parser code are fairly minimal (a nice
surprise!); the biggest addition is a
writeContextthat marks whetherthe
=operator can serve as a recovery point after error detection.Part of #38596
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?