Skip to content

bug: typechecker allows func-typed variables in string interpolation (E3041 not emitted) #1554

@SchoolyB

Description

@SchoolyB

Description

When a func-typed variable is used inside string interpolation ${}, the typechecker does not reject it. The codegen then leaks the raw C function pointer as a decimal integer string into the program output.

Repro

do greet() -> string {
    return "hi"
}

do main() {
    mut f = ()greet
    println("${f}")
}

Expected: Typechecker rejects with E3041 — function references cannot be interpolated.

Actual: Compiles and prints the raw pointer address as a decimal string (e.g., 4334929444).

Root cause

The interpolation validation only checked for bare func type via strcmp(pt->name, "func") == 0. Typed function references like func()->string have TK_FUNCTION kind, which was not being checked.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtypecheckerRelated to type checking and validation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions