Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

partial does not update function attributes correctly #847

Closed
chrisrink10 opened this issue Jan 29, 2024 · 0 comments · Fixed by #842
Closed

partial does not update function attributes correctly #847

chrisrink10 opened this issue Jan 29, 2024 · 0 comments · Fixed by #842
Assignees
Labels
issue-type:bug Something isn't working lang Issue pertaining to Basilisp language modules

Comments

@chrisrink10
Copy link
Member

partial does not update the various function attributes to match it's new signature -- instead it just copies the exact attributes from the wrapped function.

For instance, the meta is copied directly whereas in Clojure it gets a fresh nil meta:

basilisp.user=> (meta (partial ^{:meta-tag :tag} (fn [a b c] [a b c]) :a))
{:meta-tag :tag}

The existing with_meta method also continues returning the old wrapped function (without the partial application):

basilisp.user=> ((with-meta (partial f :a) {:a :b}) :b :c)
Traceback (most recent call last):
  File "/home/chris/Projects/basilisp/src/basilisp/cli.py", line 433, in repl
    result = eval_str(lsrc, ctx, ns, eof)
  File "/home/chris/Projects/basilisp/src/basilisp/cli.py", line 46, in eval_str
    last = compiler.compile_and_exec_form(form, ctx, ns)
  File "/home/chris/Projects/basilisp/src/basilisp/lang/compiler/__init__.py", line 187, in compile_and_exec_form
    return getattr(ns.module, final_wrapped_name)()
  File "<REPL Input>", line 1, in __lisp_expr___6196
  File "/home/chris/Projects/basilisp/src/basilisp/lang/runtime.py", line 1752, in wrapped_f
    return f(*args, **kwargs)
TypeError: f() missing 1 required positional argument: 'c_6188'

It also continues reporting that it has the original wrapped function's arities:

basilisp.user=> (.-arities (partial f :a))
#{3}
@chrisrink10 chrisrink10 added issue-type:bug Something isn't working lang Issue pertaining to Basilisp language modules labels Jan 29, 2024
@chrisrink10 chrisrink10 added this to the Release v0.1.0 milestone Jan 29, 2024
@chrisrink10 chrisrink10 self-assigned this Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue-type:bug Something isn't working lang Issue pertaining to Basilisp language modules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant