Skip to content

Conversation

@YoEight
Copy link
Owner

@YoEight YoEight commented Jan 10, 2026

Summary

This PR adds support for optional function parameters in the EventQL type system. Functions can now define parameters as optional, allowing them to be called with a variable number of arguments within a specified range.

Changes

New Public API

FunArgs struct

A new public type that represents function argument types with optional parameter support:

pub struct FunArgs {
    pub values: Vec<Type>,  // All argument types
    pub needed: usize,       // Number of required arguments
}

Example

// Function with optional parameter: (boolean, number?) -> string
let args = FunArgs {
    values: vec![Type::Bool, Type::Number],
    needed: 1, // Only first parameter is required
};

assert!(args.match_arg_count(1));  // Valid: only required arg
assert!(args.match_arg_count(2));  // Valid: required + optional
assert!(!args.match_arg_count(3)); // Invalid: too many args

Built-in functions update

The COUNT aggregate function now supports an optional boolean parameter:

PROJECT INTO { total: COUNT() }

PROJECT INTO { voters: COUNT(e.data.age > 30) }

Of course COUNT parameter needs to be source-bound soCOUNT(false) will get rejected at static analysis time.

@YoEight YoEight marked this pull request as ready for review January 10, 2026 17:42
@YoEight YoEight merged commit 4265bfe into master Jan 10, 2026
4 checks passed
@YoEight YoEight deleted the optional-params branch January 10, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants