This repository was archived by the owner on Oct 31, 2024. It is now read-only.
Check function arity at compile/parse time#27
Merged
Conversation
We have all the information we need to check whether or not a function is called with the correct number of arguments at compile time. Doing this will save us from having to deal with runtime errors. The runtime checking of arity still remains, but the plan is to remove it. The error message for ArityException has been changed to work better as a part of a ParseException error message, and the code that constructs ArityException messages is used by the compiler to create the ParseException message. I took the time to rewrite all default function tests so that they don't use `@Test(expected = …)` but instead catch the exception (or fail if no exception is thrown) and assert on the error message. Perhaps it's overkill to have tests for the arity and argument types of every single default function, but we have them so we might as well keep them. I added some additional tests to ParserTest to cover that arities are checked at parse/compile time.
This was referenced Sep 5, 2016
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We have all the information we need to check function call arity at compile time. This can avoid runtime errors, which is almost always a good thing. The runtime type checker still checks arity, because it really can't not or risk NPEs, but in practice there should be no arity exceptions at runtime with this code.