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

Misleading error message when method call is missing non-default argument #2068

Open
mzagozen opened this issue Jan 10, 2025 · 1 comment
Open
Labels
bug Something isn't working

Comments

@mzagozen
Copy link
Collaborator

Acton Version

0.24.1.20250110.11.13.23

Steps to Reproduce and Observed Behavior

I'm not sure, are non-default arguments in acton allowed to follow default arguments in methods, functions definitions? If yes, then compiler error message for a method is a bit misleading, referring to a tuple. Or if this is not allowed, then the compiler should flag the definition, not the call site.

Method with non-default arguments following defaults

class Bob:
    def __init__(self, first: ?str=None, second: int):
        pass

def _test_bob():
    ba = Bob(42)
    bb = Bob(second=42)  # this works!
ERROR: Error when compiling tf2 module: Type error

   |
24 |    ba = Bob(42)
   |         ^^^^^^^
keyword component(s) 'second' is not defined in tuple

Function with non-default arguments following defaults

The message is better when a function with the same order of arguments is defined:

def cob(first: ?str=None, second: int):
    pass

def _test_cob():
    cob()
ERROR: Error when compiling tf2 module: Type error

   |
27 |def cob(first: ?str=None, second: int):
   |    ^^^


   |
31 |    cob()
   |    ^^^^^
Type incompatibility between definition of and call of cob (keyword argument(s) 'second' is not defined in call)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Expected Behavior

Either way, improve the compiler error messages.

@mzagozen mzagozen added the bug Something isn't working label Jan 10, 2025
@plajjan plajjan mentioned this issue Jan 15, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant