Commit Graph

386 Commits

Author SHA1 Message Date
Brummel 65ab6c6b3a iter 23.2.3-prep2: rename remaining two 22b2 fixtures + their prose snapshot (orchestrator-inline) 2026-05-10 22:35:37 +02:00
Brummel 7289bbc9d4 iter 23.2.3-prep: reconcile workspace tests with auto-loaded prelude class Eq
The auto-loaded prelude (iter 23.2 work-in-progress) injects
`class Eq` plus three primitive instances (Eq Int, Eq Bool, Eq Str)
into every workspace. Five workspace::tests assertions broke against
this new baseline:

- iter22b1_missing_method_fires_diagnostic
- instance_without_superclass_instance_fires
- instance_overriding_nonexistent_method_fires
  Their fixtures redeclare `class Eq` (and `class Ord` in one case),
  which now collides with the prelude. Renamed each fixture's
  `Eq`/`eq` -> `TEq`/`teq` and `Ord`/`lt` -> `TOrd`/`tlt`, matching
  the scheme already used in the two earlier-renamed test_22b2
  fixtures. Method `ne` stays (does not collide). Assertion strings
  in workspace.rs updated to match.

- iter22b1_workspace_with_no_classes_has_empty_registry
- iter22b1_instance_in_class_module_loads_clean
  Their asserted registry counts assumed an otherwise-empty registry.
  Rewritten to filter by `defining_module != "prelude"`: the property
  is "no NON-prelude entries" / "exactly one fixture-owned entry",
  not raw count.

Doc comments updated alongside each assertion change so the rationale
for TEq/TOrd (collision avoidance) is local. No production code
touched.
2026-05-10 22:34:30 +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 e580f75adf test: red for mono pass mis-resolving cross-module ctor patterns
`monomorphise_workspace` re-runs `synth` on every fn body to recover
residual class constraints; the env it uses is built by
`mono::build_workspace_env`, which delegates to `build_check_env` and
produces a workspace-flat `ctor_index` (every Def::Type ctor across
every module, keyed by bare ctor name → bare type name).

`check_in_workspace` (lib.rs:1247-1258) explicitly clears that flat
index after `build_check_env` and rebuilds it per-module so that
`Pattern::Ctor`'s local-first / imports-fallback resolution at
lib.rs:2486-2521 keeps the qualified-type-name comparison at
lib.rs:2526 intact: imports-fallback yields a qualified
`resolved_type_name` (`Mod.Type`), local-hit yields a bare one.

The mono pass never does the per-module overlay, so when a body in
module B pattern-matches a ctor `C` whose Def::Type lives in imported
module A, the workspace-flat index resolves `C` locally and yields the
bare type name. The scrutinee, however, was typed against the
qualified name, and the comparison fails with
`PatternTypeMismatch { ctor: "Cons", ty: "A.Type<...>" }`.

Surfaced by iter 23.2 Task 3, which adds `class Eq a` + Eq Int/Bool/Str
instances to the prelude. Pre-Task-3 the prelude is class-free, so
`workspace_has_typeclasses(ws) == false` and the mono pass early-outs
at `mono.rs:73`. Task 3 flips the gate; every workspace now traverses
bodies, which brings the latent bug to the surface for the
pre-existing `nested_ctor_pattern_first_two_sum` and
`std_either_list_demo` E2E tests.

Sibling regressions in the same family: `mono_xmod_qualified_ref.rs`
(env.imports not seeded), commit 13b36cc (env.globals not seeded for
self-recursive fns), commit 5c5180f (env.types / env.ctor_index not
seeded for user ADTs — the original "flat ctor_index" decision that
this bug now exposes as wrong-by-construction for cross-module ctor
pattern resolution).

The minimal fixture is two modules with five defs total:
test_mono_ctor_listmod (data List a = Nil | Cons a (List a)) and
test_mono_ctor_main (class Trivial a + instance Trivial Int + a fn
that pattern-matches Cons against the imported List<Int> + a main).
The test pins the inner cause: matches against the specific
`CheckError::PatternTypeMismatch` variant with the qualified
scrutinee type and bare ctor name, so it stays RED regardless of the
prelude's typeclass content.
2026-05-10 22:16:51 +02:00
Brummel 1618182220 iter 23.2.2-fixup-doc: tighten try_emit_primitive_instance_body contract doc 2026-05-10 22:02:29 +02:00
Brummel c6168ad5d1 iter 23.2.2-fixup: emit closure adapter for primitive-instance-bodied fns 2026-05-10 22:01:00 +02:00
Brummel 736064adf4 iter 23.2.2: codegen — declare @ail_str_eq + eq__Str body intercept 2026-05-10 21:55:19 +02:00
Brummel cc2d6944c1 iter 23.2.1: runtime/str.c with ail_str_eq + unconditional link 2026-05-10 21:49:45 +02:00
Brummel c6c3c21013 plan: 23.2 Eq class + primitive instances (eq__Int/Bool/Str) 2026-05-10 21:47:49 +02:00
Brummel c461a0b5a8 iter 23.1.5: JOURNAL entry 2026-05-10 21:36:41 +02:00
Brummel 1f244379de iter 23.1.4 fixup: local-hit with mismatching type_name falls through to imports-fallback 2026-05-10 21:35:43 +02:00
Brummel aace5e3ce2 iter 23.1.4: E2E fixture — bare LT match via implicit prelude import 2026-05-10 21:32:05 +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 927f7ea38f iter 23.1.2 fixup: align workspace-root idiom + add collision test for ReservedModuleName 2026-05-10 21:16:56 +02:00
Brummel 3742583924 iter 23.1.2: load_workspace auto-injects prelude module 2026-05-10 21:13:40 +02:00
Brummel cce3d9738e iter 23.1.1: examples/prelude.ail.json — Ordering ADT skeleton 2026-05-10 21:11:06 +02:00
Brummel 9cf616a593 plan: 23.1 — Ordering ADT + prelude skeleton + auto-load 2026-05-10 21:10:27 +02:00
Brummel 9c3d29084c spec: 23 status → Approved 2026-05-10 21:04:06 +02:00
Brummel 03b6d15db4 spec: 23 — Eq/Ord Prelude (Show + heap-Str ABI deferred to next milestone) 2026-05-10 20:35:06 +02:00
Brummel 2a98b31d84 iter architect-iron-law.3: JOURNAL entry + close roadmap todo 2026-05-10 20:03:21 +02:00
Brummel 6047b38b5c iter architect-iron-law.2: extend ailang-architect with sweep-script invocation + lockstep-checklist for two known cross-file pairings 2026-05-10 20:02:29 +02:00
Brummel 67223c8487 iter architect-iron-law.1: bench/architect_sweeps.sh runs the four design-md-consolidation sweeps against DESIGN.md 2026-05-10 20:01:47 +02:00
Brummel 1f5689a952 plan: architect-iron-law extension — sweep script + lockstep-checklist 2026-05-10 20:00:40 +02:00
Brummel 1de300ed2c fieldtest close: Floats — B1 fixed, F1+G1 documented, architect-checklist queued 2026-05-10 17:14:09 +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 1ce2ff42dc fieldtest follow-up: G1 (DESIGN.md NaN-print Unspecified) + F1 roadmap entry 2026-05-10 16:59:18 +02:00
Brummel 2052f4dfcc fieldtest: floats — 4 examples, 6 findings (1 bug, 1 friction, 1 spec_gap, 3 working) 2026-05-10 16:57:38 +02:00
Brummel 741f3bbf08 audit close: Floats milestone — clean (architect/bench/rustdoc all green; carry-on) 2026-05-10 16:47:10 +02:00
Brummel 41dd2ddc1b floats iter 5: JOURNAL — iter-5 close + Floats milestone close 2026-05-10 16:40:37 +02:00
Brummel 965e628c52 floats iter 5.4: roadmap — mark Floats [x] + unblock Post-22 Prelude 2026-05-10 16:38:45 +02:00
Brummel 47b32bff3d floats iter 5.3: DESIGN.md — new §Float semantics subsection (A5 determinism contract) 2026-05-10 16:38:24 +02:00
Brummel 2d2646afa7 floats iter 5.2: DESIGN.md — Float in primitive types + refreshed builtins list 2026-05-10 16:37:42 +02:00
Brummel ea8988b529 floats iter 5.1: prose renders Float literals (finite + NaN/Inf) 2026-05-10 16:36:12 +02:00
Brummel fd287c9740 plan: floats iter 5 — prose + DESIGN.md + milestone close 2026-05-10 16:33:35 +02:00
Brummel 73d65baa81 floats iter 4: JOURNAL — iteration close (codegen + E2E) 2026-05-10 16:28:10 +02:00
Brummel 9764b616ce floats iter 4.6: codegen io/print_float + examples/floats.ail.json E2E fixture 2026-05-10 16:25:25 +02:00
Brummel bde5aafb03 floats iter 4.5: codegen Float constants nan/inf/neg_inf as hex-double SSA values 2026-05-10 16:20:37 +02:00
Brummel 613aa39f0f floats iter 4.4 fixup: float_to_str returns CodegenError::Internal instead of panic 2026-05-10 16:18:39 +02:00
Brummel 581144a4f9 floats iter 4.4: codegen neg/int_to_float/float_to_int_truncate/is_nan + float_to_str-deferred 2026-05-10 16:15:39 +02:00
Brummel 3869641a31 floats iter 4.3: codegen Float comparison arms (fcmp olt/ole/ogt/oge/UNE) + lower_eq Float 2026-05-10 16:10:13 +02:00
Brummel 2a290704df floats iter 4.2 fixup: 3-tuple return for builtin_binop_typed + classifier helper 2026-05-10 16:07:11 +02:00
Brummel 8044a4d98c floats iter 4.2: codegen arithmetic dispatch on arg type — fadd/fsub/fmul/fdiv double 2026-05-10 16:01:35 +02:00
Brummel ac5e17e541 floats iter 4.1: codegen primitive registration + Float literal hex-double lowering 2026-05-10 15:54:20 +02:00
Brummel 0c514e034b plan: floats iter 4 — codegen + runtime (Float lowering paths + E2E fixture) 2026-05-10 15:51:20 +02:00
Brummel dbec90cefd floats iter 3: JOURNAL — iteration close (typecheck + builtins) 2026-05-10 15:43:31 +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