inducer / starlark-pyo3

A Python wrapper for starlark-rust
Other
16 stars 3 forks source link

Cannot call a function with named arguments #22

Open pvcnt opened 1 day ago

pvcnt commented 1 day ago

It looks like it is impossible to call a function with named arguments. While g(1) works well, g(x=1) results in an error.

How to reproduce

Given the following snippet:

import starlark as sl

glb = sl.Globals.standard()
mod = sl.Module()

def g(x):
    print(f"g called with {x}")
    return 2 * x

mod.add_callable("g", g)

ast = sl.parse("a.star", "g(x=1)")

def load(name):
    raise FileNotFoundError(name)

sl.eval(mod, ast, glb, sl.FileLoader(load))

I obtain the following error:

error: Found `x` extra named parameter(s) for call to function
inducer commented 1 day ago

Yep, not currently implemented:

https://github.com/inducer/starlark-pyo3/blob/00f5fe7e6c8a639d31e88e9046bdb4a20815a397/src/lib.rs#L622-L641

Help welcome.