Skip to content

return inside a literal can break JVM stack #1

@fglock

Description

@fglock

return inside a literal can break JVM stack.

example workaround in List constructor:

            // emit the list element
            if (element instanceof OperatorNode && ((OperatorNode) element).operator.equals("return")) {
                // Special case for return operator: it inserts a `goto` instruction
                emitterVisitor.ctx.logDebug("visit(ListNode) return");
                emitterVisitor.ctx.mv.visitInsn(Opcodes.POP); // stop construction of RuntimeList instance
                emitterVisitor.ctx.mv.visitInsn(Opcodes.POP);
                element.accept(emitterVisitor.with(RuntimeContextType.LIST));
                return;
            } else {
                element.accept(emitterVisitor.with(RuntimeContextType.LIST));
            }

another possible workaround: use exceptions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions