GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [apex] Parser error when using CALENDAR_YEAR() in SOQL · Issue #6478 · pmd/pmd

[apex] Parser error when using CALENDAR_YEAR() in SOQL #6478

New issue
Copy link
New issue
Copy link
Closed
#6862
Closed
[apex] Parser error when using CALENDAR_YEAR() in SOQL#6478
#6862
Copy link
Assignees
adangel
Labels
a:bugPMD crashes or fails to analyse a file.in:grammarAbout the grammar of a lexer or parser, eg, a parse/lex exception
Milestone
7.27.0

Description

@andruts
andruts
opened on Mar 4, 2026
Issue body actions

Affects PMD Version:
Pipeline: 7.10.0
Visual Studio Code Extension: 7.15.0
PMD CLI: 7.22.0

Description:

SOQL with GROUP BY ROLLUP and CALENDAR_YEAR.

Exception Stacktrace:

Syntax error at 279:21: mismatched input '(' expecting {')', ','}
Syntax error at 279:41: mismatched input ',' expecting {'instanceof', ')', '[', '.', '=', '>', '<', '?.', '?', '==', '===', '!=', '<>', '!==', '&&', '||', '??', '++', '--', '+', '-', '*', '/', '&', '|', '^', '+=', '-=', '*=', '/=', '&=', '|=', '^=', '<<=', '>>=', '>>>='}
Syntax error at 284:8: missing ';' at 'ExternalId__c'
Syntax error at 284:45: missing ';' at 'NULLS'
Syntax error at 285:34: missing ';' at 'ASC'
Syntax error at 285:44: missing ';' at 'FIRST'
Syntax error at 286:21: missing ';' at '('
Syntax error at 286:46: missing ';' at 'NULLS'
Syntax error at 287:6: missing ';' at 'LIMIT'
Syntax error at 288:4: mismatched input ']' expecting {'instanceof', '[', ';', '.', '=', '>', '<', '?.', '?', '==', '===', '!=', '<>', '!==', '&&', '||', '??', '++', '--', '+', '-', '*', '/', '&', '|', '^', '+=', '-=', '*=', '/=', '&=', '|=', '^=', '<<=', '>>=', '>>>='}
[INFO] An error occurred while executing PMD.

Code Sample demonstrating the issue:

SELECT
        ExternalId__c,
        CALENDAR_YEAR(CustomDateField__c) year,
        SUM(CustomAmountField__c) amount,
        COUNT(Id) counter
      FROM
        CustomObject__c
      GROUP BY ROLLUP(
        CALENDAR_YEAR(CustomDateField__c),
        ExternalId__c
      )
      ORDER BY
        ExternalId__c ASC NULLS FIRST,
        CALENDAR_YEAR(CustomDateField__c) ASC NULLS LAST
      LIMIT 2000

Steps to reproduce:

Please provide detailed steps for how we can reproduce the bug.

  1. Run Apex Static Analysis: On File

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
CLI
Visual Studio Code

Activity

  1. andruts
    added
    a:bugPMD crashes or fails to analyse a file.
    on Mar 4, 2026
  2. LINTHESHWARS commented on Mar 4, 2026

    @LINTHESHWARS
    LINTHESHWARS
    on Mar 4, 2026
    More actions

    @andruts Could you provide more detailed steps to reproduce the issue?

  3. andruts commented on Mar 5, 2026

    @andruts
    andruts
    on Mar 5, 2026
    Author
    More actions

    @LINTHESHWARS I am facing this issue while doing static analysis.

    public with sharing class CustomRollupExample {
    
        public static void runRollup() {
    
            List<AggregateResult> results = [
                SELECT
                    ExternalId__c,
                    CALENDAR_YEAR(CustomDateField__c) year,
                    SUM(CustomAmountField__c) amount,
                    COUNT(Id) counter
                FROM CustomObject__c
                GROUP BY ROLLUP(
                    CALENDAR_YEAR(CustomDateField__c),
                    ExternalId__c
                )
                ORDER BY
                    ExternalId__c ASC NULLS FIRST,
                    CALENDAR_YEAR(CustomDateField__c) ASC NULLS LAST
                LIMIT 2000
            ];
    
            for (AggregateResult ar : results) {
    
                String externalId = (String) ar.get('ExternalId__c');
                Integer year = (Integer) ar.get('year');
                Decimal totalAmount = (Decimal) ar.get('amount');
                Integer recordCount = (Integer) ar.get('counter');
    
                System.debug('ExternalId: ' + externalId +
                             ' | Year: ' + year +
                             ' | Amount: ' + totalAmount +
                             ' | Count: ' + recordCount);
            }
        }
    }

    Output

    PS C:\worskpace\pmd-bin-7.22.0> ./bin/pmd.bat  check -d "CustomRollupExample.cls" -R rulesets/apex/quickstart.xml --verbose
    [DEBUG] Log level is at TRACE
    [DEBUG] Created new FileCollector with LanguageVersionDiscoverer(LanguageRegistry(apex, ecmascript, html, java, jsp, kotlin, modelica, plsql, pom, scala, swift, velocity, visualforce, wsdl, xml, xsl))
    [DEBUG] Adding regular file CustomRollupExample.cls.
    [TRACE] Adding file C:\worskpace\pmd-bin-7.22.0\CustomRollupExample.cls (lang: apex 60)
    [DEBUG] Rules loaded from rulesets/apex/quickstart.xml:
    [DEBUG] - ExcessiveParameterList (Apex)
    [DEBUG] - ExcessivePublicCount (Apex)
    [DEBUG] - NcssCount (Apex)
    [DEBUG] - StdCyclomaticComplexity (Apex)
    [DEBUG] - TooManyFields (Apex)
    [DEBUG] - AvoidDeeplyNestedIfStmts (Apex)
    [DEBUG] - CyclomaticComplexity (Apex)
    [DEBUG] - OperationWithLimitsInLoop (Apex)
    [DEBUG] - OperationWithHighCostInLoop (Apex)
    [DEBUG] - AvoidDirectAccessTriggerMap (Apex)
    [DEBUG] - AvoidLogicInTrigger (Apex)
    [DEBUG] - AvoidGlobalModifier (Apex)
    [DEBUG] - AvoidNonExistentAnnotations (Apex)
    [DEBUG] - AvoidHardcodingId (Apex)
    [DEBUG] - ClassNamingConventions (Apex)
    [DEBUG] - MethodNamingConventions (Apex)
    [DEBUG] - MethodWithSameNameAsEnclosingClass (Apex)
    [DEBUG] - FieldNamingConventions (Apex)
    [DEBUG] - FormalParameterNamingConventions (Apex)
    [DEBUG] - LocalVariableNamingConventions (Apex)
    [DEBUG] - PropertyNamingConventions (Apex)
    [DEBUG] - AnnotationsNamingConventions (Apex)
    [DEBUG] - ApexUnitTestClassShouldHaveAsserts (Apex)
    [DEBUG] - ApexUnitTestShouldNotUseSeeAllDataTrue (Apex)
    [DEBUG] - ApexUnitTestClassShouldHaveRunAs (Apex)
    [DEBUG] - ApexSharingViolations (Apex)
    [DEBUG] - ApexInsecureEndpoint (Apex)
    [DEBUG] - ApexCSRF (Apex)
    [DEBUG] - ApexOpenRedirect (Apex)
    [DEBUG] - ApexSOQLInjection (Apex)
    [DEBUG] - ApexXSSFromURLParam (Apex)
    [DEBUG] - ApexXSSFromEscapeFalse (Apex)
    [DEBUG] - ApexBadCrypto (Apex)
    [DEBUG] - ApexCRUDViolation (Apex)
    [DEBUG] - ApexDangerousMethods (Apex)
    [DEBUG] - ApexSuggestUsingNamedCred (Apex)
    [DEBUG] - IfStmtsMustUseBraces (Apex)
    [DEBUG] - WhileLoopsMustUseBraces (Apex)
    [DEBUG] - IfElseStmtsMustUseBraces (Apex)
    [DEBUG] - ForLoopsMustUseBraces (Apex)
    [DEBUG] - EmptyCatchBlock (Apex)
    [DEBUG] - EmptyIfStmt (Apex)
    [DEBUG] - EmptyWhileStmt (Apex)
    [DEBUG] - EmptyTryOrFinallyBlock (Apex)
    [DEBUG] - EmptyStatementBlock (Apex)
    [DEBUG] - OneDeclarationPerLine (Apex)
    [DEBUG] - ApexDoc (Apex)
    [DEBUG] - DebugsShouldUseLoggingLevel (Apex)
    [DEBUG] Runtime classpath:
    C:\worskpace\pmd-bin-7.22.0\bin\../conf;C:\worskpace\pmd-bin-7.22.0\bin\../lib/antlr4-runtime-4.9.3.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/apex-ls_2.13-6.0.2.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/apex-parser-4.4.1.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/apex-types_2.13-1.3.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/asm-9.9.1.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/better-files_2.13-3.9.2.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/checker-compat-qual-2.5.3.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/checker-qual-3.53.1.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/commons-lang3-3.20.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/common_2.13-4.15.2.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/directory-watcher-0.18.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/directory-watcher-better-files_2.13-0.18.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/error_prone_annotations-2.41.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/failureaccess-1.0.3.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/flogger-0.8.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/flogger-system-backend-0.8.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/geny_2.13-0.6.2.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/groovy-5.0.4.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/gson-2.13.2.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/gson-extras-1.3.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/guava-33.5.0-jre.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/io_2.13-4.15.2.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/j2objc-annotations-3.1.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/jline-3.21.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/jna-5.12.1.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/jsoup-1.22.1.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/jspecify-1.0.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/jsr250-api-1.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/jsr305-3.0.2.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/jul-to-slf4j-1.7.36.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/kotlin-stdlib-2.2.10.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/kotlin-stdlib-jdk7-2.2.10.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/kotlin-stdlib-jdk8-2.2.10.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/mainargs_2.13-0.5.4.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/nice-xml-messages-3.1.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/outline-parser_2.13-1.3.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/parsers_2.13-4.15.2.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pcollections-4.0.2.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/picocli-4.7.7.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-ant-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-apex-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-cli-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-coco-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-core-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-cpp-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-cs-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-css-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-dart-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-designer-7.19.2.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-fortran-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-gherkin-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-go-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-groovy-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-html-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-java-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-javascript-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-jsp-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-julia-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-kotlin-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-lua-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-matlab-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-modelica-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-objectivec-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-perl-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-php-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-plsql-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-python-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-ruby-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-rust-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-scala_2.13-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-swift-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-tsql-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-velocity-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-visualforce-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/pmd-xml-7.22.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/progressbar-0.9.5.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/rhino-1.7.15.1.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/Saxon-HE-12.9.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/scala-collection-compat_2.13-2.8.1.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/scala-json-rpc-upickle-json-serializer_2.13-1.1.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/scala-json-rpc_2.13-1.1.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/scala-library-2.13.18.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/scala-parallel-collections_2.13-1.0.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/scala-reflect-2.13.18.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/scala-xml_2.13-1.3.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/scalajs-stubs_2.13-1.0.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/slf4j-api-1.7.36.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/slf4j-simple-1.7.36.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/sobject-types-65.0.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/sourcecode_2.13-0.4.4.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/standard-types-65.0.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/summit-ast-2.4.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/trees_2.13-4.15.2.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/ujson_2.13-1.2.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/upack_2.13-1.2.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/upickle-core_2.13-1.2.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/upickle-implicits_2.13-1.2.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/upickle_2.13-1.2.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/vf-parser-1.1.0.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/xmlresolver-5.3.3-data.jar;C:\worskpace\pmd-bin-7.22.0\bin\../lib/xmlresolver-5.3.3.jar
    [DEBUG] Aux classpath: jdk.internal.loader.ClassLoaders$AppClassLoader@5c647e05
    [WARN] Progressbar rendering conflicts with reporting to STDOUT. No progressbar will be shown. Try running with argument -r <file> to output the report to a file instead.
    [TRACE] Using Apex version ''apex 60''
    [WARN] This analysis could be faster, please consider using Incremental Analysis: https://docs.pmd-code.org/pmd-doc-7.22.0/pmd_userdocs_incremental_analysis.html
    [DEBUG] MultiFile Analysis created for Optional[]
    [DEBUG] Using 16 threads for analysis
    [TRACE] Processing file (lang: apex+version:60): C:\worskpace\pmd-bin-7.22.0\CustomRollupExample.cls
    CustomRollupExample.cls -       ParseException: Parse exception: com.google.summit.SummitAST$ParseException: Failed to parse CustomRollupExample.cls:
    Syntax error at 13:29: mismatched input '(' expecting {')', ','}
    Syntax error at 13:49: mismatched input ',' expecting {'instanceof', ')', '[', '.', '=', '>', '<', '?.', '?', '==', '===', '!=', '<>', '!==', '&&', '||', '??', '++', '--', '+', '-', '*', '/', '&', '|', '^', '+=', '-=', '*=', '/=', '&=', '|=', '^=', '<<=', '>>=', '>>>='}
    Syntax error at 17:16: missing ';' at 'ExternalId__c'
    Syntax error at 17:34: missing ';' at 'NULLS'
    Syntax error at 18:29: missing ';' at '('
    Syntax error at 18:54: missing ';' at 'NULLS'
    Syntax error at 19:12: missing ';' at 'LIMIT'
    Syntax error at 20:8: extraneous input ']' expecting ';'
    [INFO] An error occurred while executing PMD.
    Run in verbose mode to see a stack-trace.
    If you think this is a bug in PMD, please report this issue at https://github.com/pmd/pmd/issues/new/choose
    If you do so, please include a stack-trace, the code sample
     causing the issue, and details about your run configuration.
  4. adangel
    changed the title [-]Parser error when using CALENDAR_YEAR() in SOQL[/-] [+][apex] Parser error when using CALENDAR_YEAR() in SOQL[/+] on Mar 5, 2026
  5. adangel
    added
    in:grammarAbout the grammar of a lexer or parser, eg, a parse/lex exception
    on Mar 5, 2026
  6. adangel commented on Mar 5, 2026

    @adangel
    adangel
    on Mar 5, 2026
    Member
    More actions

    This is actually a bug in the upstream apex-parser project, see apex-dev-tools/apex-parser#84

  7. adangel commented on Jul 6, 2026

    @adangel
    adangel
    on Jul 6, 2026
    Member
    More actions

    So, the new Apex Parser 5.1.0 has been released, which contains the grammar fix needed here: https://github.com/apex-dev-tools/apex-parser/releases/tag/v5.1.0

    However, this is not enough, we also need an updated summit-ast library - however, the it has been archived... https://github.com/google/summit-ast

    Preliminary branches:

    • summit-ast: google/summit-ast@main...adangel:summit-ast:update-apex-parser-5.1.0
    • pmd: main...adangel:pmd:apex/issue-6478-calendar-year-soql

    We probably need to adopt summit-ast...

  8. adangel
    added this to the 7.27.0 milestone on Jul 6, 2026
  9. adangel
    self-assigned this
    on Jul 10, 2026
  10. adangel
    added 2 commits that reference this issue on Jul 10, 2026

    [apex] Fix pmd#6478: Bump apex-parser from 5.0.0 to 5.1.0

    This issue will close once commit 71677b4 is merged into the 'main' branch.
    71677b4

    [doc] Update release notes (pmd#6478)

    This issue will close once commit bda187d is merged into the 'main' branch.
    bda187d
  11. adangel
    closed this as completedin #6862on Jul 22, 2026
  12. pzygielo
    added a commit that references this issue on Jul 22, 2026

    [apex] Fix pmd#6478: Bump apex-parser from 5.0.0 to 5.1.0 (pmd#6862)

    This issue will close once commit e21be45 is merged into the 'main' branch.
    e21be45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @adangel
    adangel

Labels

a:bugPMD crashes or fails to analyse a file.in:grammarAbout the grammar of a lexer or parser, eg, a parse/lex exception

Type

No type

Projects

No projects

    Milestone

    • 7.27.0

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.