Skip to content

#691 flip widens the #607 consuming-iteration gate to every Vec — 11 behavior tests red #712

Closed

Description

@ehartford

Since #691 made every Vec needs-drop, the #607-era gate ("consuming iteration
of a Vec whose elements need drop is not yet supported") now rejects plain
for v in vec for ALL element types, including Vec[i32].

Repro (post-flip compiler, e.g. out/release/bin/with):

./out/release/bin/with run test/behavior/vec_map_basic.w
error: consuming iteration of a Vec whose elements need drop is not yet
supported (#607); iterate by borrow instead: `for w in &vec`
 --> test/behavior/vec_map_basic.w:8:14

with build :test fails 11 behavior tests on this (first post-flip run of the
suite with a flip-carrying candidate): issue66_ir_text_only, it_desugar_field,
it_desugar_filter, prelude_core_mode, vec_filter_basic, vec_map_basic,
vec_map_debug, vec_map_it, vec_map_manual, vec_map_type_change_return, and one
more in the tail. The stage-1 -p/-n one-liner driver trips the same gate
(for __line in stdin.lines()).

Fork to decide: implement consuming Vec iteration (move elements out, free the
buffer, reset the source — drop-audit-sensitive lowering work), or migrate the
tests/driver to for v in &vec and accept the ergonomic regression until the
feature lands. The tests pin basic map/filter ergonomics, so migrating them
weakens mission-level pins; the diagnostic's own suggestion conflicts with
"don't make the user write what the compiler could figure out."

Found while closing the D22 Stage 6 gate (2026-07-25); everything else in the
battery is green (fixpoint stage2==stage3, move/drop audits, allocator matrix).

Activity

  1. ehartford commented on Jul 25, 2026

    @ehartford
    ContributorAuthor

    Correction after checking the specification: this is not a design fork.

    docs/with-specification.md (§13, implicit iteration) already rules it:

    // These are equivalent:
    for item in my_vec:           // compiler inserts .iter()
    for item in my_vec.iter():    // explicit (also valid)
    ...
    for item in my_vec.into_iter():   // consuming (moves elements)
    
    "The implicit `.iter()` insertion means `for x in collection:` borrows
    the collection immutably — the collection remains valid after the loop."
    

    So for v in doubled: must borrow, and the #607 gate
    (src/SemaCheck.w:9880-9890) should never see the implicit form. The current
    for-lowering treats a bare Vec iterable as by-value — a pre-flip copy-world
    artifact (the gate's own comment says "POD-element Vecs are untouched", which
    was only true while type_needs_drop(Vec[POD]) was 0). The 11 red tests are
    implementation non-conformance to the blessed iteration rule, not a feature
    gap. Consuming .into_iter() (Rust vec::IntoIter-style remainder-drop) can
    land separately; nothing red requires it.

  2. ehartford commented on Jul 27, 2026

    @ehartford
    ContributorAuthor

    Resolved by evolution — verified on v0.15.1-geb0a0cf31: the #607-era gate no longer fires. All 11 behavior fixtures named in this report pass (issue66_ir_text_only, it_desugar_field, it_desugar_filter, prelude_core_mode, vec_filter_basic, vec_map_basic, vec_map_debug, vec_map_it, vec_map_manual, vec_map_type_change_return), plain 'for j in vec' over a drop-element Vec runs and leaves the source intact, and the -n/-p one-liner driver works. The fork this issue posed (implement consuming iteration vs migrate the tests to 'for v in &vec') never had to be taken: the mission-level ergonomic pins are intact and unmigrated. A separate pre-existing leak found while auditing this — nested Vec element buffers are not freed on drop — is filed as #736.

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