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

Add a compiler warning for arity-mismatch on calls #671

Closed
chrisrink10 opened this issue Mar 28, 2022 · 0 comments · Fixed by #842
Closed

Add a compiler warning for arity-mismatch on calls #671

chrisrink10 opened this issue Mar 28, 2022 · 0 comments · Fixed by #842
Assignees
Labels
compiler Issue pertaining to compiler enhancement New feature or request

Comments

@chrisrink10
Copy link
Member

It would be helpful if the compiler at least emitted a warning when users call a function with a fixed arity (or fixed arities) with the wrong number of arguments.

@chrisrink10 chrisrink10 added enhancement New feature or request compiler Issue pertaining to compiler labels Mar 28, 2022
@chrisrink10 chrisrink10 added this to the Release v0.1.0b1 milestone Dec 29, 2023
@chrisrink10 chrisrink10 self-assigned this Jan 25, 2024
@chrisrink10 chrisrink10 modified the milestones: Release v0.1.0b1, Release v0.1.0b2, Release v0.1.0 Jan 25, 2024
chrisrink10 added a commit that referenced this issue Jan 29, 2024
Add a compile-time warning for arity mismatches on function invocations.
The warning is enabled by default (if the dev logger is enabled and
configured for at least `WARNING` level logs).

In order to facilitate this work, we also had to change the computation
of the Basilisp function `arities` attribute set. Previously this
included only fixed arities (the argument count for each non-variadic
function arity) and a `:rest` keyword if the function included a
variadic arity. Now `arities` will include all fixed arities including
the number of fixed (non-variadic) arguments to the varidic arity. This
allows for more sophisticated warnings.

As part of this bill of work, it was also required to update `partial`
to support computing a new set of `arities` for partial applications.
`functools.wraps` copies all values from `__dict__` to wrapped
functions, so partials were appearing to have the same set of arities as
their wrapped function which was never correct.

Fixes #671 
Fixes #847
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Issue pertaining to compiler enhancement New feature or request
Projects
Development

Successfully merging a pull request may close this issue.

1 participant