Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
Description
I have the following program that crashes the compiler
class Main { public static void main(String[] args) { var func = {int x = 1, Double[] y = new Double[0] -> x}; func() } }
Actual behavior
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: General error during canonicalization: toIndex = 1java.lang.IndexOutOfBoundsException: toIndex = 1 at java.base/java.util.AbstractList.subListRangeCheck(AbstractList.java:509) at java.base/java.util.ArrayList.subList(ArrayList.java:1191) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.checkForbiddenSpreadArgument(StaticTypeCheckingVisitor.java:4036) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:3678) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethodCallExpression(StaticCompilationVisitor.java:223) at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:78) at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:117) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:212) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitExpressionStatement(StaticTypeCheckingVisitor.java:2337) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:175) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:72) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:139) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:118) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.lambda$visitConstructorOrMethod$31(StaticTypeCheckingVisitor.java:2834) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.doWithTypeCheckingExtensions(StaticTypeCheckingVisitor.java:466) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:2834) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.startMethodInference(StaticTypeCheckingVisitor.java:2817) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethod(StaticTypeCheckingVisitor.java:2796) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitConstructorOrMethod(StaticCompilationVisitor.java:193) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethod(StaticCompilationVisitor.java:208) at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1331) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1324) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.lambda$visitClass$3(StaticTypeCheckingVisitor.java:502) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.doWithTypeCheckingExtensions(StaticTypeCheckingVisitor.java:466) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitClass(StaticTypeCheckingVisitor.java:502) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitClass(StaticCompilationVisitor.java:155) at org.codehaus.groovy.transform.sc.StaticCompileTransformation.visit(StaticCompileTransformation.java:68) at org.codehaus.groovy.control.customizers.ASTTransformationCustomizer.call(ASTTransformationCustomizer.groovy:303) at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:952) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:698) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:672) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:653) at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:312) at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:241) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:166) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:206) at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:190)1 error
Tested against master (commit: f00b8810ce77d284ac32d07fd7cc5dbece9aedfc)
Attachments
Issue Links
- is related to
-
GROOVY-10597 STC: support spread arguments for varargs
- Closed