imperative-programming #51

Merged
st merged 46 commits from imperative-programming into main 2026-07-25 21:17:10 +02:00
Owner
No description provided.
st added 46 commits 2026-07-25 21:16:41 +02:00
Ir.If replaces the if-as-Match desugar (drops FromIf/match_origin).
return is a Never-typed early-exit expression; codegen ret + fresh
dead block; TRE via return->recur. See docs/plans/return-statement.md.
- thread return_ty through instance-method and mutual-recursion (SCC)
  body inference (Phase C blockers: return was rejected there)
- constrain_call coerces call/core-call args so a Never arg fills any
  slot, matching operators (fixes f(return x)/f(undefined)); preserves
  the param-first unify direction for nat-witness identity
Arm body runs to the next | or end; multi-statement arms and a
trailing return work like an if branch. Empty arm = Unit. Drop the
now-redundant do-blocks in stdlib/iterators + examples/cat.
while cond do <block> end; break/continue target the innermost loop
(Never-typed, error outside a loop). Codegen is a CFG back-edge reusing
the return block-termination substrate. Also fixes a pre-existing bug:
call-site evidence/dict allocas were emitted at the insertion point, not
the entry block, so any interface/operator call in a loop leaked stack
(overflow at ~5M iters) -- hoisted via entry_alloca. See docs/plans/loops.md.
Adds is_mut to typed_name (let=false, let mut=true) and the mut keyword.
A mut binding is monomorphic (the value restriction made explicit): the
generalization gate becomes (not is_mut && is_value). Assignment gating
and the := form are the next steps. See docs/plans/let-mut.md.
Assign node; resolve gates on a mut local (scope.locals is a local_info
map; lambda AND named-local-fn boundaries make captured locals read-only).
Codegen: mut scalar = entry-block Cell, heap = Rooted slot. Loop
accumulation without a ref-cell struct. See docs/plans/let-mut.md.
A `use` cycle through a re-export-only module (the prelude) silently stripped
its re-exports from importers — declared names survived the cycle, re-exported
ones did not. Pre-seed re-exports to a fixpoint and preserve them across Phase 1
so a type-only module cycle (Lists -> Iterators -> Prelude -> Lists) resolves.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
An in-scope forall Iface bound is a local dictionary: a parked multi-participant
dispatch improves its output participant(s) from a unique matching given, and
instance-set shape propagation is guarded off for a given-owned participant. Lets
a generic consumer of Iterate[C, State] type-check without splitting the interface.

Plan: docs/plans/mptc-given-dispatch.md
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Inference pins (output participant via given, two-givens ambiguity) and a stdlib
Iterate JIT end-to-end consumer.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A value binding has no call site to fix a nat and is monomorphized once, so a
generalized (still-free) nat is undetermined, not polymorphic. Reject it
(UndeterminedNat) like an unresolved type instead of letting it reach codegen and
silently monomorphize to 0. Annotated values ground the nat first; function
return-type nat-polymorphism (caller-determined) is unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Move Iterate into std/Iterators, drop the legacy Iterable/Iterator split, add
the Array Iterate instance, and migrate the examples and tests to the unified
interface.
style.md's if/else examples gain the required trailing `end`; the emacs mode's
keyword/type/constant lists track the lexer — adds while/break/continue/return/
mut/do/as, drops stale non-keywords, and fixes Bool/True/String spellings.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
for <pat> in <iter> do … end over the Iterate interface, expanded at resolve to
let $it = Iterate.iterate(iter) in while True do match Iterate.next($it) with
None -> break | Some(pat) -> body end end. Prelude re-exports Iterate.
examples/imperative.aml showcases for over Array/List, mutable structs, and
break/continue. Plan: docs/plans/for-loops.md

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
st merged commit 5b9ae139a2 into main 2026-07-25 21:17:10 +02:00
st deleted branch imperative-programming 2026-07-25 21:17:14 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
st/amelie!51
No description provided.