Skip to content

usize/isize struct fields pass 'with check' but fail at codegen with 'unresolved type' #7

Closed

Description

@ehartford

Current behavior

type Point = {
    x: usize,
    y: usize,
}

fn main:
    let p = Point { x: 1, y: 2 }

with check says ok. But with test or with build fails:

error: unresolved type for field 'x' in struct 'Point'
error: unresolved type for field 'y' in struct 'Point'
error: code generation failed

Why this is bad

  1. with check lies — it says ok for code that cannot compile.
  2. The error says "unresolved type" for usize, which is a builtin type. The user has no idea what to do.
  3. usize works fine in function parameters and local variables, just not struct fields. This inconsistency is extremely confusing.

Expected behavior

Either:

  • Fix it: usize/isize should work in struct fields (they are fundamental types).
  • Reject early: with check should report the limitation:
    error: 'usize' is not yet supported as a struct field type
     --> point.w:2:8
    2 |     x: usize,
      |        ^^^^^
      = help: use 'i64' instead
    

Repro

cat > /tmp/usize_struct.w << 'EOF'
type Point = { x: usize, y: usize }
test "usize_field":
    let p = Point { x: 1, y: 2 }
    assert(p.x == 1)
EOF
with check /tmp/usize_struct.w   # says "ok"
with test /tmp/usize_struct.w    # crashes with "unresolved type"

Activity

  1. added
    bug
    error-messages
    on Mar 20, 2026
  2. ehartford commented on Mar 21, 2026

    @ehartford
    ContributorAuthor

    Fixed on main in d8bb583. Codegen now resolves usize and isize for struct field declarations, and test/cases/behav_struct_usize_fields.w covers the regression.

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

    bugerror-messages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions