You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Thodoris Sotiropoulos (Jira)" <ji...@apache.org> on 2022/04/28 11:17:00 UTC
[jira] [Created] (GROOVY-10602) Compiler crash in class generation when combining lambdas and default args
Thodoris Sotiropoulos created GROOVY-10602:
----------------------------------------------
Summary: Compiler crash in class generation when combining lambdas and default args
Key: GROOVY-10602
URL: https://issues.apache.org/jira/browse/GROOVY-10602
Project: Groovy
Issue Type: Bug
Components: Static Type Checker
Reporter: Thodoris Sotiropoulos
This is a quite rare test case
I have the following program
{code}
import java.util.function.Supplier;
class Test {
public static void test(Closure<Byte> x = {Byte v -> { Closure<Byte> y = { Supplier<Byte> d = { -> v } -> d.get() }; y() }}) {
null
}
}
{code}
h3. Actual behaviour
The above test program leads to a compiler crash with the following stack trace
{code}
>>> a serious error occurred: BUG! exception in phase 'class generation' in source unit 'test.groovy' tried to get a variable with the name v as stack variable, but a variable with this name was not created
>>> stacktrace:
BUG! exception in phase 'class generation' in source unit 'test.groovy' tried to get a variable with the name v as stack variable, but a variable with this name was not created
at org.codehaus.groovy.classgen.asm.CompileStack.getVariable(CompileStack.java:303)
at org.codehaus.groovy.classgen.asm.ClosureWriter.loadReference(ClosureWriter.java:151)
at org.codehaus.groovy.classgen.asm.ClosureWriter.writeClosure(ClosureWriter.java:126)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitClosureExpression(AsmClassGenerator.java:858)
at org.codehaus.groovy.ast.expr.ClosureExpression.visit(ClosureExpression.java:110)
at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateEqual(BinaryExpressionHelper.java:397)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitDeclarationExpression(AsmClassGenerator.java:833)
at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:89)
at org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:611)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:817)
at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41)
at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:94)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:748)
at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:70)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:602)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:547)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:686)
at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1131)
at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1124)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:365)
at org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:797)
at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:937)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:692)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:666)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:647)
at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:311)
at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:240)
at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:165)
at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:205)
at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:189)
{code}
h3. Expected behaviour
Compile successfully
Tested against master (commit: 5c468cd352f37fb5c599a3f51534ffcc55b339ed)
--
This message was sent by Atlassian Jira
(v8.20.7#820007)