Skip to content

Generic body uses a field of an unbounded type parameter: fn f[T](x: T) -> i32: x.v passes check and prints 0 #1981

Closed

Description

@ehartford

Found by the Sema/MIR wave (wave-sema). fn f[T](x: T) -> i32: x.v called as f(3) passes with check and prints 0. A generic body is checked against its bounds, not its instantiations: T has no bound that provides a field v, so x.v must be a check error at the definition ("type parameter 'T' has no field 'v'; add a bound…"). Today the field access is apparently resolved per instantiation and an i32 has no field, yet a value is produced — a silent fallback. Failing-first: a compile_errors fixture; also confirm a bounded T whose trait provides an accessor still works.

Activity

  1. added
    bug
    on Oct 3, 2026
  2. ehartford commented on Oct 3, 2026

    @ehartford
    ContributorAuthor

    Fixed on main in c884c1c (stack #2001 → #2010, seed-driven battery GREEN on b932ef6, tree identical to main). Fixture coverage is in the stack's commits.

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