Skip to content

A tuple element type through a generic facade's &T view: field access fails inference, and a call-contract BUG in MirLower on the benchmark's shape #2565

Closed

Description

@ehartford

A tuple as a facade's element type breaks two ways where a record works.

use std.collections.deque.Deque
fn main:
    var d = Deque[(i32, i32)].new()
    d.push_back((1, 2))
    print(d.get(0).0)

gives cannot infer type parameter 'T' for this call; the argument's shape does not match the parameter type that mentions 'T' at the print (Deque.get returns &T, here &(i32, i32), and .0 through that view does not type). The same shape in test/benchmark/stc_engines.w's slot-shape round (var d = Deque[(i32, i32)].new(), d.push_back((i, i)), d.get(i as isize).0 as i64) fails later and harder:

BUG: user generic call lacks a concrete contract: body=14306(deque_slots_round) call=0 node=580099 sig=-1 mono=0 [src/MirLower.w:19465 MirModule.validate_generic_call_contracts]

With type Pair { a: i32, b: i32 } in place of the tuple both compile and run (the benchmark uses Pair now). A tuple element in a List ([(1, 2)], .0 on xs[0]) works, so it is the generic method's &T view of a tuple, not tuples in containers.

Route: with analyze repro.w 'explain:origin:main' for the view, then audit:resolution on the benchmark's shape for the missing contract.

Activity

  1. ehartford commented on Oct 24, 2026

    @ehartford
    ContributorAuthor

    Fixed in #2614 (main 23dd9db). Root cause: a tuple type argument at a static call (Deque[(i32, i32)].new()) parses as a tuple expression in type-level position, which resolve_type_level_arg_expr did not resolve; the instance then had no concrete argument, its methods no specialization contract (the MirLower BUG) and the view's field no type (the inference error). The same type in an annotation always worked. Fixture test/behavior/behav_tuple_type_argument.w.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions