Skip to content

Imported record types inside Vec fields can make len() hit an internal compiler error #37

Closed

Description

@ehartford

Current behavior

A module that stores an imported record type inside a Vec[...] field can pass with check, but with run fails during code generation when calling len() on that field.

with check output:

ok

with run output:

FATAL: unhandled MIR_INTRINSIC_GENERIC_CALL sym=len node_kind=27
error: code generation failed
error: run failed

Minimal repro

lib/demo/core.w

pub type Value = {
    raw: u64,
}

lib/demo/combo.w

use demo.core

type State = {
    values: Vec[Value],
}

fn len_i32(state: State) -> i32:
    state.values.len() as i32

pub fn sentinel -> i32:
    0

main.w

use demo.combo

fn main:
    assert(true)

Run:

mkdir -p /tmp/wbug_issue_len/lib/demo
cat > /tmp/wbug_issue_len/lib/demo/core.w <<EOF
pub type Value = {
    raw: u64,
}
EOF
cat > /tmp/wbug_issue_len/lib/demo/combo.w <<EOF
use demo.core

type State = {
    values: Vec[Value],
}

fn len_i32(state: State) -> i32:
    state.values.len() as i32

pub fn sentinel -> i32:
    0
EOF
cat > /tmp/wbug_issue_len/main.w <<EOF
use demo.combo

fn main:
    assert(true)
EOF
with check /tmp/wbug_issue_len/main.w
with run /tmp/wbug_issue_len/main.w

Notes

  • If Value is defined in the same file as State, this works.
  • The failure appears to be specifically tied to Vec[ImportedRecord] stored inside another record and then calling len() on that field.
  • This is an internal compiler error and should not happen for valid input.

Activity

  1. added
    bug
    on Mar 23, 2026
  2. ehartford commented on Mar 23, 2026

    @ehartford
    ContributorAuthor

    Fixed on main in 619a674 with a regression test covering imported Vec field len().

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions