Repository navigation
Report too few builtin arguments in unchecked calls - #1025
Merged
Merged
Conversation
date(timezone("UTC")) passed the checker and panicked at run time;
reject it in Validate and guard Func. Extra arguments of a Fast builtin
in an unchecked call stayed on the stack and leaked into the enclosing
expression; pop them. Name exact argument ranges in the arity error.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The checker does not check the arguments of a call on an unknown value, so a builtin with too few arguments there, e.g.
fn().N(join()), failed at run time withindex out of rangeorstack underflow.The compiler derives the minimum arity from the builtin's
Types(and requires one argument forFastbuiltins) and, when a call has too few, emits anOpThrowwithinvalid number of arguments for join (expected 1 or 2, got 0). Valid calls compile exactly as before.Extra arguments of a
Fastbuiltin in such a call were left on the stack and leaked into the enclosing expression (x + fn().N(upper("a", "b"))returned"aB"). They are now evaluated and popped; the builtin still gets the last argument, as before.date(timezone("UTC"))passed the checker and panicked at run time.Validatenow rejects it, andFuncguards it for unchecked calls, as it does fordate().max,min,mean,median,firstandlasthave noTypes, and with no arguments quietly returned nil or 0. TheirFuncnow returns the sameinvalid number of argumentserror.Extra arguments to
Func/Safebuiltins are still ignored: the generated corpus has working expressions that pass them ($env?.[first(0, ok)],toBase64(foobar)in a pipe), so rejecting them would break existing programs.Based on #943 by @thevilledev, done in the compiler instead of per builtin.
Fixes #941