Skip to content

bug - Decorated functions lose default-argument call-site filling #703

@dannymeijer

Description

@dannymeijer

Area

  • Compiler (frontend/backend/codegen)

Summary

Expected: Decorating a function should preserve default-argument call-site behavior. If a plain function can be called without an argument because the parameter has a default, the decorated version should support the same call shape.

Actual: A decorated function with a default argument is emitted as a Rust function that requires the argument. A zero-argument call to the decorated function fails during generated Rust compilation with E0061.

This blocks InQL PR #45 from exposing a clean count() / count(expr) aggregate helper through the existing registry decorator model. The non-decorated helper shape works, but the decorated public helper loses the default argument.

Reproduction steps

  1. Create test_decorated_default_probe.incn with:
def identity(func: (int) -> int) -> (int) -> int:
    return func

@identity
def decorated_default(value: int = 7) -> int:
    return value

def plain_default(value: int = 7) -> int:
    return value

def test_decorated_default_probe() -> None:
    assert plain_default() == 7
    assert decorated_default() == 7
  1. Run:
incan test test_decorated_default_probe.incn
  1. Observe that plain_default() has its default filled, while decorated_default() is emitted as requiring one argument.

Output / logs

error[E0061]: this function takes 1 argument but 0 arguments were supplied
  --> generated test code for decorated_default()

note: function defined here
  generated decorated function has shape similar to:
  fn decorated_default(__incan_arg_0: i64) -> i64

The exact generated file path varies by machine and is intentionally omitted here.

Environment

OS: macOS
Rust: current v0.3 development toolchain
Incan: release/v0.3, observed while testing the rc19-era compiler used by InQL PR #45
Command: incan test test_decorated_default_probe.incn

Related context

Related but not duplicate:

This bug is narrower: local decorated functions should preserve default-argument call-site filling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingincan compilerSuggestions, features, or bugs related to the Compiler (frontend/backend/codegen)

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions