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

Compile-time check for missing args in private calls #1579

Merged

Conversation

iamdefinitelyahuman
Copy link
Contributor

What I did

Added a check for calls to private functions where no args are given but the call expects args. Prior to this PR, the following code would compile:

@private
def bar(a: int128) -> int128:
    return 1

@public
def foo() -> int128:
    return self.bar()

I also tweaked the inputs to pack_arguments, allowing for code highlights in the exceptions raised there.

How I did it

  • vyper.parser.self_call.call_self_private
    • added a check when no args are given that raises if args were expected
  • vyper.parser.parser_utils.pack_arguments
    • replaced input arg pos with stmt_expr, derive position using getpos(stmt_expr)
    • include stmt_expr when raising exceptions

How to verify it

Run the tests. I've added tests to check for args when none should be given, no args when args should be given, and the wrong number of args.

Cute Animal Picture

image

@jacqueswww
Copy link
Contributor

LGTM 🐎

@fubuloubu fubuloubu merged commit f7e18e6 into vyperlang:master Aug 24, 2019
@iamdefinitelyahuman iamdefinitelyahuman deleted the self-call-missing-args branch August 25, 2019 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants