Skip to content

Panic on function call with >16 operands: call operand count exceeds SWAP16 #233

Description

@micahscopes

Description

The EVM backend panics when lowering a function call with more than 16 arguments:

thread 'main' panicked at crates/codegen/src/stackalloc/stackify/sym_stack.rs:247:9:
call operand count exceeds SWAP16

Minimal Reproduction

fn many_params(
    _ a1: u256, _ a2: u256, _ a3: u256, _ a4: u256,
    _ a5: u256, _ a6: u256, _ a7: u256, _ a8: u256,
    _ a9: u256, _ a10: u256, _ a11: u256, _ a12: u256,
    _ a13: u256, _ a14: u256, _ a15: u256, _ a16: u256,
    _ a17: u256,
) -> u256 {
    let sum = a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8
    sum + a9 + a10 + a11 + a12 + a13 + a14 + a15 + a16 + a17
}

pub contract Crash {
    init() {}
    recv TestMsg {
        Test {} -> u256 {
            many_params(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)
        }
    }
}

16 params works. 17 panics.

Impact

This blocks typed EC pairing wrappers (BN254 4-pair pairing needs 24 u256 args) and any function with a wide parameter list. The workaround is to pass data through memory instead of as function arguments.

Expected behavior

The compiler should either:

  1. Automatically spill excess arguments to memory, or
  2. Emit a clear error diagnostic instead of panicking

Environment

  • Fe: v26.0.0-alpha.7
  • Sonatina: bfa66a0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions