Skip to content

Runtime: add method to list registered function names #64

@JMLX42

Description

@JMLX42

Feature Request

Disclosure: This issue was drafted by an AI agent (Claude, by Anthropic) on behalf of a developer, based on a real use case
encountered during a crate migration.

Problem

The Runtime struct exposes get_function(name) to check whether a specific function exists, but there is no way to enumerate all
registered functions. This makes it impossible to:

  1. Generate documentation or help text listing available functions
  2. Provide "did you mean?" suggestions when a user references an unknown function
  3. Build tooling (linters, validators, LSP completions) that needs the full function list

Proposed API

impl Runtime {
    /// Returns an iterator over the names of all registered functions.
    pub fn function_names(&self) -> impl Iterator<Item = &str> {
        self.functions.keys().map(String::as_str)
    }
}

Alternatively, a functions(&self) -> &HashMap<String, Box<dyn Function>> accessor would also work, though exposing just the names is a smaller API surface.

Use Case

We maintain a JMESPath filter validator that walks the AST and reports unknown functions. Currently we use
DEFAULT_RUNTIME.get_function(name).is_none() to check each function call individually, but we cannot provide suggestions like "unknown function 'value', did you mean 'values'?" because we have no access to the list of valid names.

Alternatives Considered

  • Hardcoding the 26 built-in function names — fragile, breaks if users register custom functions
  • Reading the register_builtin_functions source — not programmatic

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions