Skip to content

emit-c: generic struct instantiations reached only through methods/fields are not emitted as C types (Wrap_str_, Box_Node_, BTreeMap_i32__str_ unknown type name) #1562

Closed

Description

@ehartford

Found while checking D61 (#1480) backend parity; the baseline (main ae609cd) compiler emits the same C, so this predates D61.

type Wrap[T] { value: T }
impl[T] Debug for Wrap[T]:
    fn debug_str() -> str: "wrapped"
fn main:
    let w = Wrap { value: "x" }
    print(w.debug_str())

with build --emit-c then cc: error: unknown type name Wrap_str_ (the prototype with_str Wrap_debug_str__receiver__...(const Wrap_str_* _1) precedes any definition). Same for type Node { next: Option[Box[Node]] } (Box_Node_) and a BTreeMap[i32, str] (BTreeMap_i32__str_) even without any formatting. Together with #1434 (HashMap traversal) these are the emit-c gaps that keep the D61 map/Box/generic-impl fixtures LLVM-only; every fixture the C backend can compile prints byte-identical output.

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