Typechecks for default parameters and int arrays#1596
Conversation
|
I like this code, but note that the method for typechecking is (slightly) different than the approach in ann_assign: https://github.com/ethereum/vyper/blob/ab39d4e9c5168eff2646dd29e23d7212654b636d/vyper/parser/stmt.py#L141-L151 I am good merging this so long as we add a note to this effect since we should reify the two code paths at some point. |
|
linking #764 (comment) |
|
@charles-cooper I think some refactoring is possible so one of these checks isn't needed. It's late here, will have a look and hopefully push more tomorrow morning. |
|
OK I take it back.. There are a lot of type checks happening in |
|
LGTM |
What I did
How I did it
vyper/parser/parser_utils.pyinmake_setter, raiseInvalidLiteralExceptionwhen left type isBaseTypeand right value is out of bounds. This works for arrays as well becausemake_setterrecursively calls itself until the left type is reduced to aBaseType.vyper/signatures/function_signature.pymoved param check tovalidate_default_valuesto allow recursive calls for checking arraysHow to verify it
I added test cases for default parameters and array assignment.
Cute Animal Picture