Problem
Currently vera run file.vera --fn f -- 42 10 only supports integer arguments. Non-integer values produce an error:
$ vera run file.vera --fn greet -- Alice
Error: Invalid integer argument(s): Alice
This means functions like fn greet(@String -> @Unit) cannot be called from the CLI at all. Float-parameter functions like fn area(@Float64 -> @Float64) also cannot be invoked directly.
The only workaround for strings is IO.args(), which requires restructuring the function to use the IO effect and call IO.args() internally rather than receiving arguments as parameters.
Current behavior
In vera/cli.py:866-884, everything after -- is parsed strictly as integers:
fn_args = [int(a) for a in raw_args] # line 873
The type annotation confirms: fn_args: list[int | float] | None (but float parsing is never attempted).
In vera/codegen/api.py:515-537, execute() validates that the argument count matches the WASM function parameter count, but has no type-aware dispatch.
Proposed solution
Use the compiled WASM function signature to determine argument types and parse CLI args accordingly:
- Inspect
func_type.params from the WASM function to get the expected types (i64, f64, i32, i32 i32 for strings)
- Parse each CLI arg based on the expected WASM type:
i64 (Int/Nat) -> int(arg)
f64 (Float64) -> float(arg)
i32 (Bool) -> arg.lower() in ("true", "1")
i32 i32 (String) -> allocate in WASM memory, pass (ptr, len)
- String allocation requires access to the WASM store and memory before calling the function -- allocate the UTF-8 bytes and pass the (offset, length) pair as two i32 params
Scope
Related
IO.args() remains available as the string-based alternative (returns Array<String>)
- The
@Unit parameter convention (spec requires main(@Unit -> @Unit) but this is not enforced by the checker)
Problem
Currently
vera run file.vera --fn f -- 42 10only supports integer arguments. Non-integer values produce an error:This means functions like
fn greet(@String -> @Unit)cannot be called from the CLI at all. Float-parameter functions likefn area(@Float64 -> @Float64)also cannot be invoked directly.The only workaround for strings is
IO.args(), which requires restructuring the function to use the IO effect and callIO.args()internally rather than receiving arguments as parameters.Current behavior
In
vera/cli.py:866-884, everything after--is parsed strictly as integers:The type annotation confirms:
fn_args: list[int | float] | None(but float parsing is never attempted).In
vera/codegen/api.py:515-537,execute()validates that the argument count matches the WASM function parameter count, but has no type-aware dispatch.Proposed solution
Use the compiled WASM function signature to determine argument types and parse CLI args accordingly:
func_type.paramsfrom the WASM function to get the expected types (i64,f64,i32,i32 i32for strings)i64(Int/Nat) ->int(arg)f64(Float64) ->float(arg)i32(Bool) ->arg.lower() in ("true", "1")i32 i32(String) -> allocate in WASM memory, pass (ptr, len)Scope
-- 3.14)-- hello "hello world")-- true false)Related
IO.args()remains available as the string-based alternative (returnsArray<String>)@Unitparameter convention (spec requiresmain(@Unit -> @Unit)but this is not enforced by the checker)