Skip to content

fix(grammar): allow empty component list in RecordPattern#5008

Merged
jlerbsc merged 1 commit into
javaparser:masterfrom
jlerbsc:master
May 3, 2026
Merged

fix(grammar): allow empty component list in RecordPattern#5008
jlerbsc merged 1 commit into
javaparser:masterfrom
jlerbsc:master

Conversation

@jlerbsc

@jlerbsc jlerbsc commented May 3, 2026

Copy link
Copy Markdown
Collaborator

Per JLS 14.30, the component list in a RecordPattern is optional:
RecordPattern: ReferenceType ( [ComponentPatternList] )
The PatternList() production in java.jj required at least one
component, causing a parse error on valid patterns like Point()
or case Pair() in switch expressions.
Wrap the content of PatternList() in an optional block [ ... ]
so that an empty parenthesised list produces an empty NodeList
rather than a parse failure. Also update the Javadoc comment to
match the JLS definition.
Add emptyRecordPatternListShouldWork() test to PatternExprTest
to cover the zero-component case.

@codecov

codecov Bot commented May 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.694%. Comparing base (2146cfc) to head (b3b12a3).
⚠️ Report is 29 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff               @@
##              master     #5008       +/-   ##
===============================================
+ Coverage     58.657%   58.694%   +0.036%     
- Complexity      2564      2592       +28     
===============================================
  Files            699       700        +1     
  Lines          40121     40188       +67     
  Branches        7314      7323        +9     
===============================================
+ Hits           23534     23588       +54     
- Misses         13620     13630       +10     
- Partials        2967      2970        +3     
Flag Coverage Δ
AlsoSlowTests 58.694% <ø> (+0.036%) ⬆️
javaparser-core 58.694% <ø> (+0.036%) ⬆️
javaparser-symbol-solver 58.694% <ø> (+0.036%) ⬆️
jdk-10 58.266% <ø> (+0.039%) ⬆️
jdk-11 58.265% <ø> (+0.037%) ⬆️
jdk-12 58.265% <ø> (+0.037%) ⬆️
jdk-13 58.265% <ø> (+0.037%) ⬆️
jdk-14 58.494% <ø> (+0.034%) ⬆️
jdk-15 58.496% <ø> (+0.036%) ⬆️
jdk-16 58.472% <ø> (+0.036%) ⬆️
jdk-17 58.621% <ø> (+0.036%) ⬆️
jdk-18 58.621% <ø> (+0.036%) ⬆️
jdk-8 58.102% <ø> (+0.040%) ⬆️
jdk-9 58.264% <ø> (+0.039%) ⬆️
macos-latest 58.669% <ø> (+0.036%) ⬆️
ubuntu-latest 58.664% <ø> (+0.036%) ⬆️
windows-latest 58.676% <ø> (+0.036%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 3 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1f5ee1a...b3b12a3. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jlerbsc jlerbsc merged commit d8ea322 into javaparser:master May 3, 2026
35 checks passed
@jlerbsc jlerbsc added this to the next release milestone May 3, 2026
@jlerbsc jlerbsc added the PR: Fixed A PR that offers a fix or correction label May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Fixed A PR that offers a fix or correction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant