Lift argument type checking out of the function type definition #6148
Labels
domain: vrl
Anything related to the Vector Remap Language
type: enhancement
A value-adding code change that enhances its existing functionality.
Functions currently can be fallible because of two reasons:
parse_json
).sha1
).The former means its fallibility depends on the runtime characteristics of the incoming events. There's nothing we can do about this at compile-time other than enforcing people to handle the error case of a function call.
The latter is something we have more control over at compile-time, through our progressive type system.
This issue proposes moving type checking out of functions and into the compiler itself.
This means two things:
For the first point, we already have something like this in place, but it predates the new
TypeDef
andvalue::Kind
system, since this check is done at runtime. We'll have to swap this out with the newvalue::Kind
set-up.For the latter, this is essentially another check we add to our
FunctionCall
expression. We already do a ton of compile-time checks there (function arity, parameter names, missing required arguments, abort-call on infallible functions), so it's just a matter of adding another check to this list:Get the expected value kind for each parameter, and compare that against the progressively collected type information for the provided argument. If they match, we're good, if not, we add an error diagnostic related to the incompatible argument type, similar to this:
ref #6146
The text was updated successfully, but these errors were encountered: