Skip to content

Add iterable for loops #31

Description

@itsfuad

Goal

Add iterable for loops after existing conditional and infinite-loop foundation.

Already delivered

  • Conditional for condition { ... } parsing, checking, CFG, MIR, and backend lowering.
  • Infinite for { ... } form.
  • Break and continue control-flow support.

Remaining scope

  • Add direct iteration over fixed arrays, dynamic arrays, and slice views.
  • Define binding forms for value-only and index-plus-value iteration.
  • Preserve copy-versus-borrow rules for move-only elements; do not extract move-only elements by indexed value access.
  • Define iterator protocol only after optional narrowing in Add optional narrowing and payload access #28 makes a next -> ?T contract usable.
  • Avoid dynamic dispatch for statically known arrays and slices.
  • Allow dynamic dispatch only when source is already interface or dynamic.

Dependencies

Validation

  • Parser, typechecker, ownership, HIR, CFG, MIR, and backend tests.
  • Positive x_test fixtures for fixed arrays, dynamic arrays, slice views, index-value bindings, and infinite loops.
  • Negative fixtures for invalid sources, mutation conflicts, and move-only extraction.
  • Runtime cleanup tests for break, continue, return, and temporary iterable owners.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestlanguage-modelPeeper language model, ownership, pointer, optional, array/slice work

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions