-
-
Notifications
You must be signed in to change notification settings - Fork 17
Warn at compile time on arity mismatch for function invocation #842
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
Conversation
5316647
to
d3cb1ee
Compare
9dff082
to
87719bf
Compare
@@ -43,3 +50,13 @@ | |||
PyCollectionForm = Union[dict, list, set, tuple] | |||
ReaderForm = Union[LispForm, IRecord, ISeq, IType, PyCollectionForm] | |||
SpecialForm = Union[llist.PersistentList, ISeq] | |||
|
|||
|
|||
class BasilispFunction(Protocol): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically also IWithMeta
but MyPy does not allow Protocols to inherit from non-Protocols and I don't want to mess with trying to change IWithMeta
to a Protocol type now.
@@ -30,7 +30,7 @@ def pytest_collect_file(file_path: Path, path, parent): | |||
"""Primary PyTest hook to identify Basilisp test files.""" | |||
if file_path.suffix == ".lpy": | |||
if file_path.name.startswith("test_") or file_path.stem.endswith("_test"): | |||
return BasilispFile.from_parent(parent, fspath=path, path=file_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was constantly hitting us with deprecation warnings on test runs.
@@ -3223,7 +3231,6 @@ def _interop_prop_to_py_ast( | |||
assert node.op == NodeOp.HOST_FIELD | |||
|
|||
target_ast = gen_py_ast(ctx, node.target) | |||
assert not target_ast.dependencies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this was here. The dependencies are passed on a couple lines down.
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. Nowarities
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 ofarities
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