Skip to content

bug - a local function called inside a lambda emits its unmangled name #1492

Description

@dannymeijer

Area

Compiler (frontend/backend/codegen)

Summary

A call to a module-level function emits a mangled incan-v1 symbol at a direct call site, but the unmangled source name when the same call appears inside a lambda. The unmangled name does not exist in the generated crate, so the code fails with E0425.

Both call sites below name the same function in the same module. Only the one inside the lambda is emitted wrongly.

Reproduction steps

def cfg_predicate(predicate: &Predicate, snapshot: CfgSnapshot) -> Option[bool]:
    ...


def evaluate(expression: Expression, snapshot: CfgSnapshot) -> Option[bool]:
    if cfg_predicate(predicate, snapshot) == None:          # direct call - emits mangled, resolves
        return None
    return expression.eval((predicate) => cfg_predicate(predicate, snapshot))   # in a lambda - emits bare name
incan oven bake --project .

Output / logs

Generated Rust, direct call — mangled and resolvable:

if __incan_v1_000100000000000000116f76656e5f6c6f63616c5f696e74616b65...(predicate, snapshot.clone())

Generated Rust, same function inside the lambda — bare name, undefined:

let result: Option<bool> = expression
    .eval(|predicate| cfg_predicate(&predicate, snapshot.clone()));
error[E0425]: cannot find function `cfg_predicate` in this scope
    --> src/rust_activation.rs:1080:35

The function itself is emitted correctly under its mangled name elsewhere in the same file, so this is purely the reference inside the lambda body.

Environment

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

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

    Type

    Projects

    • Status
      Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions