Description
Have you tried to resolve this issue yourself first?
- I confirm I have gone through the above steps and still have an issue to report
Bug Description
When running SFGE engine, we see that when ?? is used in a for loop, there is an error
Example snippet
for (Account a : aList ?? new List<Account>()) { system.debug('do something'); }
I assume this is a bug/issue with underlying AST parser or similar as the ?? operator is relatively new in Apex
Output / Logs
2025-05-20 00:23:01 ERROR Sfge:159 - Unexpected exception while loading graph
com.salesforce.exception.UnexpectedException: vp[FirstChild->true], vp[BeginLine->29], vp[DefiningType_CaseSafe->EXAMPLECLASS...], vp[LastChild->true], vp[DefiningType->EXAMPLECLASS...], vp[EndLine->29], vp[childIdx->0], vp[BeginColumn->4]
at com.salesforce.graph.build.GremlinUtil.getChildren(GremlinUtil.java:60) ~[sfge-1.0.0.jar:?]
at com.salesforce.graph.build.MethodPathBuilderVisitor.visitForEachStatement(MethodPathBuilderVisitor.java:235) ~[sfge-1.0.0.jar:?]
at com.salesforce.graph.build.MethodPathBuilderVisitor._visit(MethodPathBuilderVisitor.java:130) ~[sfge-1.0.0.jar:?]
at com.salesforce.graph.build.MethodPathBuilderVisitor._visit(MethodPathBuilderVisitor.java:159) ~[sfge-1.0.0.jar:?]
at com.salesforce.graph.build.MethodPathBuilderVisitor._visit(MethodPathBuilderVisitor.java:159) ~[sfge-1.0.0.jar:?]
at com.salesforce.graph.build.MethodPathBuilderVisitor._visit(MethodPathBuilderVisitor.java:159) ~[sfge-1.0.0.jar:?]
at com.salesforce.graph.build.MethodPathBuilderVisitor.apply(MethodPathBuilderVisitor.java:97) ~[sfge-1.0.0.jar:?]
at com.salesforce.graph.build.AbstractApexVertexBuilder.afterInsert(AbstractApexVertexBuilder.java:169) ~[sfge-1.0.0.jar:?]
at com.salesforce.graph.build.AbstractApexVertexBuilder.buildVertices(AbstractApexVertexBuilder.java:153) ~[sfge-1.0.0.jar:?]
at com.salesforce.graph.build.AbstractApexVertexBuilder.buildVertices(AbstractApexVertexBuilder.java:125) ~[sfge-1.0.0.jar:?]
at com.salesforce.graph.build.AbstractApexVertexBuilder.buildVertices(AbstractApexVertexBuilder.java:35) ~[sfge-1.0.0.jar:?]
at com.salesforce.graph.build.CustomerApexVertexBuilder.build(CustomerApexVertexBuilder.java:21) ~[sfge-1.0.0.jar:?]
at com.salesforce.graph.build.Util.buildGraph(Util.java:39) ~[sfge-1.0.0.jar:?]
at com.salesforce.graph.ops.GraphUtil.loadSourceFilesAndFolders(GraphUtil.java:170) ~[sfge-1.0.0.jar:?]
at com.salesforce.Sfge$Dependencies.loadSourceFilesAndFoldersToGraph(Sfge.java:249) ~[sfge-1.0.0.jar:?]
at com.salesforce.Sfge.execute(Sfge.java:153) [sfge-1.0.0.jar:?]
at com.salesforce.Sfge.process(Sfge.java:103) [sfge-1.0.0.jar:?]
at com.salesforce.Sfge.main(Sfge.java:71) [sfge-1.0.0.jar:?]
Steps To Reproduce
- Write apex class containing ?? in for loop.
- run SFGE engine covering aforementioned code
- refer to logs
Expected Behavior
?? should be accepted as is valid json.
Operating System
Windows 11
Salesforce CLI Version
@salesforce/cli/2.88.6 win32-x64 node-v22.14.0
Code Analyzer Plugin (code-analyzer) Version
code-analyzer 5.0.0 (>=5.0.0 <6.0.0-0)
Node Version
v22.14.0
Java Version
openjdk version "17.0.11" 2024-04-16 LTS OpenJDK Runtime Environment Zulu17.50+19-CA (build 17.0.11+9-LTS) OpenJDK 64-Bit Server VM Zulu17.50+19-CA (build 17.0.11+9-LTS, mixed mode, sharing)
Python Version
No response
Additional Context (Screenshots, Files, etc)
No response
Workaround
bring ?? outside of for loop, assign variable, then use in for loop.
Urgency
Low