Skip to content

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

Merged
fubuloubu merged 3 commits into
vyperlang:masterfrom
iamdefinitelyahuman:self-call-missing-args
Aug 24, 2019
Merged

Compile-time check for missing args in private calls#1579
fubuloubu merged 3 commits into
vyperlang:masterfrom
iamdefinitelyahuman:self-call-missing-args

Conversation

@iamdefinitelyahuman

Copy link
Copy Markdown
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
Copy Markdown
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