| 1525 | } |
| 1526 | |
| 1527 | func TestVM_OpCall_InvalidNumberOfArguments(t *testing.T) { |
| 1528 | // Test that the VM validates argument count at runtime. |
| 1529 | // Compile without Env() so compiler generates OpCall without type info. |
| 1530 | program, err := expr.Compile(`fn(1, 2)`) |
| 1531 | require.NoError(t, err) |
| 1532 | |
| 1533 | // Run with a function that has different arity |
| 1534 | env := map[string]any{ |
| 1535 | "fn": func(a int) int { return a }, |
| 1536 | } |
| 1537 | |
| 1538 | _, err = expr.Run(program, env) |
| 1539 | require.Error(t, err) |
| 1540 | require.Contains(t, err.Error(), "invalid number of arguments") |
| 1541 | } |
| 1542 | |
| 1543 | func TestVM_OpCall_InvalidNumberOfArguments_Variadic(t *testing.T) { |
| 1544 | // Test variadic function with too few arguments. |