Goal
Add an array(...) function that accepts an arbitrary number of positional arguments and returns them as an Expressif array.
This complements array literal syntax by supporting array construction from evaluated expressions at runtime.
Motivation
Array literals are appropriate for static data:
But expressions sometimes need to construct an array dynamically from evaluated values, especially inside other functions such as record(...).
For example:
record(
yoy:=array(
record(year:=2024, total:=...),
record(year:=2025, total:=...),
record(year:=2026, total:=...)
)
)
This is useful when the elements are expressions rather than literals and avoids overloading array-literal syntax with runtime-construction semantics.
Expected behavior
The function accepts zero or more positional arguments:
array()
array(1)
array(1, 2, 3)
array(.foo, .bar | upper, add(1, 2))
and returns the evaluated arguments in order as an array.
Conceptually:
array(expr1, expr2, expr3)
↓ evaluate each argument
{value1, value2, value3}
Variadic parameters
The function should exercise/support an unbounded positional parameter list in the function metadata and binder.
If the current function parameter model cannot represent variadic arguments, introduce the smallest reusable mechanism needed so other functions can use the same capability later.
Spread
Where spread arguments are supported, array(...) should compose naturally with them:
The spread values should be inserted at their argument position while preserving order.
Typing
The return type should be inferred from the evaluated/bound argument types where possible.
Examples:
array(1, 2, 3) -> Array<Numeric>
array("a", "b") -> Array<Text>
For heterogeneous arguments, use the existing Expressif common-type / Any rules rather than introducing array-specific coercion semantics.
For array(), use the existing representation for an empty array when no contextual element type can be inferred.
Evaluation semantics
Arguments must be evaluated in declaration order.
The resulting array is materialized by definition; this function constructs a new array rather than transforming an input sequence.
Introspection and documentation
Expose array through the normal function catalog/introspection metadata and add it to docs/_data/function.json following the existing source-of-truth conventions.
Document that array(...) is the runtime-expression counterpart of array literal syntax.
Acceptance criteria
- Add canonical
array(...) function.
- Accept zero or more positional arguments.
- Evaluate arguments in order and return their values as an Expressif array.
- Support arguments that are arbitrary expressions, including
record(...).
- Support spread arguments where the language already supports spread.
- Reuse or introduce a generic variadic-parameter capability rather than hard-coding parser/binder behavior only for
array.
- Infer the array element type using the existing type/common-type rules.
- Handle heterogeneous and empty arrays consistently with the existing type model.
- Expose the function through introspection.
- Add the function to
docs/_data/function.json.
- Add conformance/tests for empty, single-element, multi-element, heterogeneous, nested-record, expression-valued, and spread cases.
Example
record(
yoy:=array(
record(year:=2024, total:=100),
record(year:=2025, total:=120),
record(year:=2026, total:=150)
)
)
This should produce a record whose yoy field contains an array of three records.
Goal
Add an
array(...)function that accepts an arbitrary number of positional arguments and returns them as an Expressif array.This complements array literal syntax by supporting array construction from evaluated expressions at runtime.
Motivation
Array literals are appropriate for static data:
But expressions sometimes need to construct an array dynamically from evaluated values, especially inside other functions such as
record(...).For example:
This is useful when the elements are expressions rather than literals and avoids overloading array-literal syntax with runtime-construction semantics.
Expected behavior
The function accepts zero or more positional arguments:
and returns the evaluated arguments in order as an array.
Conceptually:
Variadic parameters
The function should exercise/support an unbounded positional parameter list in the function metadata and binder.
If the current function parameter model cannot represent variadic arguments, introduce the smallest reusable mechanism needed so other functions can use the same capability later.
Spread
Where spread arguments are supported,
array(...)should compose naturally with them:The spread values should be inserted at their argument position while preserving order.
Typing
The return type should be inferred from the evaluated/bound argument types where possible.
Examples:
For heterogeneous arguments, use the existing Expressif common-type /
Anyrules rather than introducing array-specific coercion semantics.For
array(), use the existing representation for an empty array when no contextual element type can be inferred.Evaluation semantics
Arguments must be evaluated in declaration order.
The resulting array is materialized by definition; this function constructs a new array rather than transforming an input sequence.
Introspection and documentation
Expose
arraythrough the normal function catalog/introspection metadata and add it todocs/_data/function.jsonfollowing the existing source-of-truth conventions.Document that
array(...)is the runtime-expression counterpart of array literal syntax.Acceptance criteria
array(...)function.record(...).array.docs/_data/function.json.Example
This should produce a record whose
yoyfield contains an array of three records.