Commit Graph

92 Commits

Author SHA1 Message Date
Brummel 91498016b2 iter ct.3.2: mono overlay narrowed to env.types only; rename to apply_per_module_types_overlay 2026-05-11 09:37:07 +02:00
Brummel 97bb5e71fd iter ct.2.3: Term::Ctor synth direct lookup; delete imports-fallback + dead AmbiguousType 2026-05-11 09:21:36 +02:00
Brummel edb694fdce iter ct.2.2-doctidy: refresh stale doc-comments on UnknownCtorInPattern and mono_xmod_ctor_pattern 2026-05-11 09:16:20 +02:00
Brummel 0044467425 iter ct.2.2-tidy: remove unused Bag fixture from cross_module_ws helper 2026-05-11 09:14:17 +02:00
Brummel 0ca5b3d567 iter ct.2.2-followup: delete dead AmbiguousCtor variant + refresh stale comment + fold redundant re-match
Quality-review follow-up on ct.2.2 (b3c3b60).

- Delete CheckError::AmbiguousCtor: its sole producer (the Pattern::Ctor
  imports-fallback) was removed in ct.2.2, leaving the variant, the
  code()/ctx() arms, and the diagnostic.rs doc-comment as dead surface.
  Workspace grep confirms no remaining Rust consumers. AmbiguousType
  stays (it still has a Term::Ctor producer, scheduled for symmetric
  removal in ct.2.3).
- Refresh the per-module-overlay rationale comment in check_in_workspace:
  it still cited the now-defunct Pattern::Ctor local-first / imports-
  fallback path. The overlay's current job is duplicate detection plus
  bare-name lookups for local Term::Ctor synth.
- Fold the awkward re-match in type_check_pattern: the first match on
  expected now binds scrutinee_args alongside resolved_type_name /
  resolved_td / resolved_owning_module, deleting the second match +
  unreachable!(). Collapse the any-then-expect ctor lookup into a single
  find().ok_or(UnknownCtorInPattern).

Build green, 449+ tests green across the workspace.
2026-05-11 09:13:12 +02:00
Brummel b3c3b6088e iter ct.2.2: Pattern::Ctor type-driven lookup; delete imports-fallback 2026-05-11 09:07:59 +02:00
Brummel 78ccbcee9c iter ct.2.1: qualify_local_types on class-method channel + Forall constraints recursion 2026-05-11 09:00:06 +02:00
Brummel 5e653ff536 iter ct.1.5a-followup: forall-constraints recursion + docstring + drop iteration-tag comments
Three Minor items from the ct.1.5a quality review:

1. normalize_type_for_registry now recurses into
   Type::Forall.constraints[].type_, symmetric to walk_type. Closes a
   latent gap: a Forall with bare cross-module constraint types reaching
   the registry would have produced a key disagreeing with the qualified
   form. RED test: ct1_5a_normalize_recurses_into_forall_constraints.

2. Documented the bare-name limitation on Registry::type_def_module:
   two modules each defining 'type Foo' collide at insert; the proper
   fix (re-key as (owning_module, bare_name)) is out of ct.1's scope.

3. Removed the four iter-tag explanatory paragraphs at the
   normalize_type_for_lookup call sites (check/lib.rs check_fn,
   mono.rs three sites). Replaced each with a one-line pointer to the
   helper's docstring per project comment policy.
2026-05-11 01:39:26 +02:00
Brummel 7872ccfc23 iter ct.1.5a: registry-side normalize-before-hash 2026-05-11 01:32:21 +02:00
Brummel 84dcc46645 fix: mono.rs per-module env.ctor_index overlay (same family as 13b36cc / 5c5180f)
The mono pass re-runs synth on every fn body to recover residual class
constraints. build_workspace_env (delegating to build_check_env) leaves
env.types and env.ctor_index workspace-flat. The synth path for cross-
module Pattern::Ctor / Term::Ctor resolution depends on a per-module
shape — local-first lookup, then imports-fallback that produces a
qualified type name. Without the overlay, the local-flat hit short-
circuits the fallback and yields a bare type name, mismatching the
qualified scrutinee/pattern from the sibling path with
CheckError::PatternTypeMismatch.

Add a per-module overlay helper that clears and rebuilds both
env.types and env.ctor_index from the current module's Def::Type list
— mirroring check_in_workspace at lib.rs:1257-1287 — and apply it at
the two mono entry points that re-walk bodies: the Phase 3 rewrite
loop in monomorphise_workspace and collect_targets_workspace_wide.

Pinned by tests/mono_xmod_ctor_pattern.rs (e580f75); also unblocks
the latent E2E regressions nested_ctor_pattern_first_two_sum,
std_either_list_demo, and ordering_match_via_prelude_prints_1 that
surfaced once the typeclass gate in workspace_has_typeclasses flipped
to true.
2026-05-10 22:23:53 +02:00
Brummel 47d95d0c60 iter 23.1.3 fixup: clarify imports-fallback anchor + comment on env.imports vs env.module_imports duplication 2026-05-10 21:28:53 +02:00
Brummel 24af13e7e0 iter 23.1.3 fixup: cover AmbiguousType branch with cross-module test 2026-05-10 21:25:26 +02:00
Brummel 842df380a4 iter 23.1.3: implicit prelude import + symmetric bare-type-name imports-fallback in Term::Ctor synth 2026-05-10 21:24:16 +02:00
Brummel 6be5abf23a fix: Pattern::Lit::Float typecheck-reject is unreachable through check_module 2026-05-10 17:10:31 +02:00
Brummel 23b625f326 test: red for Pattern::Lit::Float not rejected through full check pipeline
Pins fieldtest finding B1 (docs/specs/2026-05-10-fieldtest-floats.md).
DESIGN.md and JOURNAL Floats.3 promise that pattern-matching on a
Float literal is hard-rejected at typecheck via
CheckError::FloatPatternNotAllowed, but the rejection only fires when
typecheck is reached directly. The full check pipeline runs
ailang_core::desugar::desugar_module first, and build_eq rewrites
Pattern::Lit { Literal::Float } arms into (== scrutinee 1.5_FLOAT)
before typecheck — so the existing iter-3.4 reject arm at lib.rs:2316
is unreachable on input flowing through check / check_module /
check_workspace.

The existing reject_float_pattern_in_match test in builtins.rs calls
synth(...) directly on a hand-built Term::Match, bypassing desugar; it
passes today but does not protect the spec'd property. This new test
exercises check(&m) end-to-end and asserts the FloatPatternNotAllowed
error — currently fails because check returns Ok(CheckedModule).

GREEN side handed off to skills/implement mini-mode.
2026-05-10 17:04:12 +02:00
Brummel d6da5c26b1 floats iter 3.4: typecheck rejects Pattern::Lit Float with FloatPatternNotAllowed 2026-05-10 15:40:33 +02:00
Brummel fd3f74cfa0 floats iter 3.3: install Float constants nan/inf/neg_inf + io/print_float effect op 2026-05-10 15:35:19 +02:00
Brummel 60a4c687b3 floats iter 3.2: install neg/int_to_float/float_to_int_truncate/float_to_str/is_nan 2026-05-10 15:31:14 +02:00
Brummel 6890aa244f floats iter 3.1 fixup: correct stale ==-comparison comment + asymmetric Float test args + drop spec-section reference 2026-05-10 15:28:55 +02:00
Brummel 0981804dd3 floats iter 3.1: widen +/-/*/// and !=/</<=/>/>= to polymorphic forall a 2026-05-10 15:24:13 +02:00
Brummel ec2811194b floats iter 1.1: Literal::Float variant + canonical hex serde + drift-test anchors 2026-05-10 14:36:08 +02:00
Brummel 557bf57cdb iter 22-tidy.4: mono::primitive_surface_name delegates to ailang-core 2026-05-10 04:18:46 +02:00
Brummel 5fd95e4e9f iter 22-tidy.4: route 4 matches! sites through is_primitive_name 2026-05-10 04:15:47 +02:00
Brummel c3fd1c08a3 iter env-unify.audit: tidy stale Env docs, pin-test docstring; queue types/ctor_index shape 2026-05-10 02:36:27 +02:00
Brummel d7e333fdf7 iter env-unify.2: drop redundant overlay comments 2026-05-10 02:28:54 +02:00
Brummel 2ab9d77113 iter env-unify.2: check_in_workspace consumes build_check_env 2026-05-10 02:26:24 +02:00
Brummel 92b94afa2a iter env-unify.1: rustdoc fixup (re-anchor check_in_workspace doc, drop transient task tag) 2026-05-10 02:19:24 +02:00
Brummel d6870d7a62 iter env-unify.1: extract build_check_env, mono uses it 2026-05-10 02:16:21 +02:00
Brummel a9c685ded8 fix: mono pass seeds env.imports for qualified cross-module refs in class workspace 2026-05-10 01:23:07 +02:00
Brummel 13b36ccb0f fix: mono pass seeds env.globals for recursive top-level fn in class workspace 2026-05-10 01:10:31 +02:00
Brummel 5c5180fc48 fix: mono pass seeds env.types and env.ctor_index for user ADTs 2026-05-09 22:43:54 +02:00
Brummel b59820b737 iter 22b.3.7: synthetic fixture — class+instance compiles, runs, prints 5 2026-05-09 21:28:41 +02:00
Brummel 7f260b82ad iter 22b.3.6: fix — quality-review (shadow-aware walker, cross-mod test, Option-typed targets, const helper) 2026-05-09 21:21:33 +02:00
Brummel d1b590ceab iter 22b.3.6: call-site rewrite — same/cross module qualified names 2026-05-09 21:07:58 +02:00
Brummel e8018d48b6 iter 22b.3.5: fix — quality-review (chained-call test, hoist class_index, drop noise comments) 2026-05-09 20:59:43 +02:00
Brummel dd87b36e00 iter 22b.3.5: workspace fixpoint loop — dedup + synth-append 2026-05-09 20:52:07 +02:00
Brummel d2954010ea iter 22b.3.4: fix — quality-review (zero-arg test, drop what-comments + param-name pin) 2026-05-09 20:45:56 +02:00
Brummel d6084a71fb iter 22b.3.4: synthesise_mono_fn — instance body + class default fallback 2026-05-09 20:41:45 +02:00
Brummel 9f86c072dc iter 22b.3.3: fix — revert dead pub(crate), reuse build_module_types, drop defensive unwrap
Quality-review follow-up to 89311ee:

- Revert `substitute_rigids` to private. Task 3 does not call it; the
  visibility bump was forward-looking for Task 4 (synthesise_mono_fn).
  Task 4 will re-bump it in the same diff that uses it.
- Promote `build_module_types` to pub(crate); drop the inline
  reimplementation in `mono::build_workspace_env`. Removes drift risk
  between the two paths.
- Replace defensive `unwrap_or_default()` on `build_module_globals`
  with `expect(...)` naming the pre-condition. Silent default violated
  CLAUDE.md "no defensive validation in internal code paths".
- Add a one-line drift-risk reminder at the top of `build_workspace_env`
  flagging that it and `check_in_workspace` both populate `Env`.

Build clean; all 5 typeclass_22b3 tests green; no workspace regressions.
2026-05-09 20:36:52 +02:00
Brummel 89311ee20b iter 22b.3.3: collect_mono_targets — synth-replay residual gathering 2026-05-09 20:31:12 +02:00
Brummel c77fd1b85e iter 22b.3.2: fix — drop speculative Float (plan-text overreach)
Float is referenced nowhere else in the codebase; the plan-text
listed it aspirationally. Restored parity with the four other
primitive enumerations across the crate. When Float lands as a
real type (post-22b.4 Prelude work, if at all), the arm gets
re-added in the same iter that introduces Type::float().

Deferred (not part of this fix):
- Shared-constant extraction across the four primitive enumeration
  sites (linearity.rs:143, lib.rs:1232/2214, mono.rs) — workspace-
  level cleanup belonging to the milestone-22 audit phase.
- pub mod mono vs sibling pub use lift::lift_letrecs style — plan
  prescribed pub mod for 22b.3 because Tasks 3-7 add multiple pub
  items reached by integration tests; per-item pub use would
  proliferate.
2026-05-09 20:25:51 +02:00
Brummel 028227587b iter 22b.3.2: mono_symbol — primitive surface forms + hash for compound 2026-05-09 20:21:24 +02:00
Brummel 108115f7dd iter 22b.3.1: fix — quality-review (doc reframe + class-present test) 2026-05-09 20:18:20 +02:00
Brummel 209074ee5d iter 22b.3.1: mono pass skeleton — identity for class-free workspaces 2026-05-09 20:12:36 +02:00
Brummel 47bec74b26 iter 22b.2.10: fix — positive green-path test, drop dead let _ = ws
Adds the missing positive counterpart to the no-instance test:
`show 42` with `instance Show Int` PRESENT must typecheck green.
This guards against registry-keying or threading bugs that would
otherwise sneak past the negative-only test (an empty registry at
typecheck time, or a key shape mismatch, would silently fire
no-instance even when the instance exists).

Also drops the dead `let _ = ws;` and its stale comment in
`check_in_workspace` — the line above already consumes
`ws.registry`, so the explicit drop is redundant. The remaining
comment is folded into the registry-threading comment so the
"registry is the only thing threaded" rationale is preserved.
2026-05-09 19:13:32 +02:00
Brummel 3600e82ec2 iter 22b.2.10: no-instance per-fn diagnostic 2026-05-09 19:07:46 +02:00
Brummel b741a8ba05 iter 22b.2.9: fix — superclass-walk tests, simplify class_superclasses map shape 2026-05-09 18:59:15 +02:00
Brummel 7cff741632 iter 22b.2.9: missing-constraint per-fn diagnostic 2026-05-09 18:51:39 +02:00
Brummel afa06a3f3d iter 22b.2.8: fix — fold double-match, IndexMap parity, broader contract test 2026-05-09 18:37:49 +02:00
Brummel 17605a3327 iter 22b.2.8: register class methods in module globals 2026-05-09 18:33:01 +02:00