-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
a:bugPMD crashes or fails to analyse a file.PMD crashes or fails to analyse a file.in:grammarAbout the grammar of a lexer or parser, eg, a parse/lex exceptionAbout the grammar of a lexer or parser, eg, a parse/lex exception
Milestone
Description
Affects PMD Version:
PMD 7.9.0 (10b47319e42bb817df69d29196ceca8fdb94b461, 2024-12-27T12:29:08Z)
Java version: 21.0.6, vendor: Ubuntu, runtime: /usr/lib/jvm/java-21-openjdk-amd64
Description:
A function call in a function definition fails to parse when there's a +
operator as one, or the, argument. Presumably happens with any other operators as well.
The full example is https://github.com/Qualtagh/OracleDBUtils/blob/master/p_utils.9.sql#241.
Exception Stacktrace:
% pmd ast-dump --language=plsql -i <<EOF
function distinguishXML() return text is
begin
return trim(x + y);
end;
/
EOF
Reading from stdin...
net.sourceforge.pmd.lang.ast.ParseException: Parse exception in file 'stdin' at line 3, column 17: Encountered "+".
Was expecting one of:
")" ...
"||" ...
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.generateParseException(PLSQLParserImpl.java)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.jj_consume_token(PLSQLParserImpl.java)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.TrimExpression(PLSQLParserImpl.java:43175)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.FunctionCall(PLSQLParserImpl.java:15346)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.PrimaryPrefix(PLSQLParserImpl.java:46183)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.PrimaryExpression(PLSQLParserImpl.java:46123)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.IsOfTypeCondition(PLSQLParserImpl.java:45365)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.IsNullCondition(PLSQLParserImpl.java:44859)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.UnaryExpressionNotPlusMinus(PLSQLParserImpl.java:44422)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.UnaryExpression(PLSQLParserImpl.java:44252)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.MultiplicativeExpression(PLSQLParserImpl.java:43811)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.AdditiveExpression(PLSQLParserImpl.java:43697)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.RelationalExpression(PLSQLParserImpl.java:43457)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.EqualityExpression(PLSQLParserImpl.java:43387)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.ConditionalAndExpression(PLSQLParserImpl.java:43339)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.ConditionalOrExpression(PLSQLParserImpl.java:43291)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.Expression(PLSQLParserImpl.java:42378)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.ReturnStatement(PLSQLParserImpl.java:37798)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.UnlabelledStatement(PLSQLParserImpl.java:25003)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.Statement(PLSQLParserImpl.java:25818)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.ProgramUnit(PLSQLParserImpl.java:7823)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.Global(PLSQLParserImpl.java:871)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParserImpl.Input(PLSQLParserImpl.java:139)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParser.parseImpl(PLSQLParser.java:86)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParser.parseImpl(PLSQLParser.java:21)
at net.sourceforge.pmd.lang.ast.impl.javacc.JjtreeParserAdapter.parse(JjtreeParserAdapter.java:36)
at net.sourceforge.pmd.util.treeexport.TreeExporter.run(TreeExporter.java:84)
at net.sourceforge.pmd.util.treeexport.TreeExporter.export(TreeExporter.java:59)
at net.sourceforge.pmd.cli.commands.internal.TreeExportCommand.execute(TreeExportCommand.java:111)
at net.sourceforge.pmd.cli.commands.internal.AbstractPmdSubcommand.call(AbstractPmdSubcommand.java:30)
at net.sourceforge.pmd.cli.commands.internal.AbstractPmdSubcommand.call(AbstractPmdSubcommand.java:16)
at picocli.CommandLine.executeUserObject(CommandLine.java:2045)
at picocli.CommandLine.access$1500(CommandLine.java:148)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2465)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2457)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2419)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2277)
at picocli.CommandLine$RunLast.execute(CommandLine.java:2421)
at picocli.CommandLine.execute(CommandLine.java:2174)
at net.sourceforge.pmd.cli.PmdCli.main(PmdCli.java:24)
Code Sample demonstrating the issue:
function distinguishXML() return text is
begin
return trim(x + y);
end;
/
Similarly, select trim(x + y) from foo;
also fails with the same error, which looks like the same situation to me and should be valid?
Running PMD through: CLI
% java -version
openjdk version "21.0.6" 2025-01-21
OpenJDK Runtime Environment (build 21.0.6+7-Ubuntu-124.04.1)
OpenJDK 64-Bit Server VM (build 21.0.6+7-Ubuntu-124.04.1, mixed mode, sharing)
Metadata
Metadata
Assignees
Labels
a:bugPMD crashes or fails to analyse a file.PMD crashes or fails to analyse a file.in:grammarAbout the grammar of a lexer or parser, eg, a parse/lex exceptionAbout the grammar of a lexer or parser, eg, a parse/lex exception