Try to fix yield with expression containing dots#3361
Conversation
|
On the CI, I get following error: In IntelliJ, this test is green. Locally, with Longer error: |
|
Hi @koppor you have to use TestUtils.assertEqualsStringIgnoringEol to compare 2 string without the test being sensitive at the end of the line. |
|
I added the string comparison. The other error still is there - maybe my grammar "fix" messed up some special case. Currently, I have no clue how to continue here. |
|
|
||
| // Note that we explicitly care about line endings when handling lexical preservation. | ||
| assertEqualsString(expectedCode, actualCode); | ||
| TestUtils.assertEqualsStringIgnoringEol(expectedCode, actualCode); |
There was a problem hiding this comment.
You are changing behavior that is intentional!
Note that we explicitly care about line endings when handling lexical preservation.
There was a problem hiding this comment.
Then I did not get your comment #3361 (comment) right. Reverted bbfc0d7.
There was a problem hiding this comment.
Apologies, without context (note the comment on line 79) it wasn't obvious from the quoted errors that this was a place where line endings were important.
|
I updated the PR to contain two commits:
|
|
@MysterAitch The PR goal was to fix a grammar issue. Can you approve the @koppor 's proposal? |
| MethodCallExpr methodCallExpr = (MethodCallExpr) yieldStmt.getExpression(); | ||
| IntegerLiteralExpr firstArgument = (IntegerLiteralExpr) methodCallExpr.getArguments().get(0); | ||
| assertEquals(1, firstArgument.asNumber()); | ||
| } |
There was a problem hiding this comment.
Hmmm, these ought to go to YieldStmtTest
|
I find it weird that the BlockStatement grammar has to be changed for this - it has been fine for years. Can you explain the fix, @koppor ? |
Within a I am still investigating, but it appears that our definition of a Consider the following grammar entries from the JLS: |
|
The PR appears to fix the yield problem, but breaks the error recovery code (multiple tests no longer pass). @matozoid -- Perhaps you are able to advise on this, please? |
|
What's the error recovery problem you see, @MysterAitch ? |
I was trying to use the Maybe, the added test cases are useful for a "proper" fix? |
|
This PR is closed because JavaParser 3.24.7 correctly parse yield statement. |
Details at #3364.
This PR adds a test case for the case that after yield a method is called. Example:
yield Collections.emptyList().Error:
Expected: No error