Skip to content

codegen: arrow-literal in class ctor body emits IR with missing @ sigil on lambda reference #587

@cs01

Description

@cs01

Bug

An arrow-literal assigned to a field inside a class constructor body emits malformed LLVM IR: store i8* __lambda_N, ... missing the @ sigil. Clang rejects the IR.

Example shape:

class Foo {
  cb: (x: string) => void;
  constructor() {
    this.cb = (x) => console.log(x);  // ← codegen emits broken IR here
  }
}

Workaround used in lib/net.ts (PR #585): declare a module-level named function (e.g., _netNoopCb) and assign the reference: this.cb = _netNoopCb.

Impact

Blocks idiomatic class initialization with callback fields. Forces module-level helpers that bloat the lib surface.

Likely fix location

src/codegen/ — lambda name emission. Probably a one-character fix (missing @ prefix in the IR print step).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions