eclipse-jdt / eclipse.jdt.core

Eclipse Public License 2.0
157 stars 125 forks source link

[23] Unexpected operand at stack top error with double as switch type #2928

Closed jarthana closed 1 week ago

jarthana commented 1 week ago

Test case:

public class X {
    public boolean foo(double d) {
        boolean b;
        switch (d) {
            case 1d -> b = true;
            default -> b = false;
        }
        return b;
    }
} 

The ECJ crashes with the following exception: Caused by: java.lang.AssertionError: Unexpected operand at stack top at org.eclipse.jdt.internal.compiler.codegen.OperandStack.pop(OperandStack.java:111) at org.eclipse.jdt.internal.compiler.codegen.CodeStream.tableswitch(CodeStream.java:7569) at org.eclipse.jdt.internal.compiler.ast.SwitchStatement.generateCode(SwitchStatement.java:836) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:387) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:323) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:759) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:829) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:416) at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:935)