Skip to content

Zero-argument function auto-call breaks explicit calls with parentheses #193

Description

@coderabbitai

Problem Description

The new zero-argument function auto-call feature introduced in PR #191 causes a behavioral regression for zero-argument functions invoked with explicit parentheses.

Current Behavior

When a zero-argument user-defined function is called explicitly with parentheses (e.g., my_action()), the following happens:

  1. The function expression Expression::Variable("my_action", ...) is evaluated
  2. The new auto-call logic in Expression::Variable immediately invokes the function and returns its result (e.g., Value::Null)
  3. Expression::FunctionCall then attempts to treat that result as a function
  4. This results in an error like "Cannot call Null" instead of executing the action once

Expected Behavior

Zero-argument functions should work correctly whether:

  • Referenced as a bare variable (auto-call): my_action
  • Called explicitly with parentheses: my_action()

Both should execute the function once and return its result.

Impact

This is a critical regression that breaks existing code using explicit function calls with parentheses for zero-argument functions.

References

Affected Code

  • src/interpreter/mod.rs: Expression::Variable (auto-call logic)
  • src/interpreter/mod.rs: Expression::FunctionCall (callee evaluation)

This issue was created as a follow-up to code review feedback.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions