Commit Graph

414 Commits

Author SHA1 Message Date
Brummel 727d2c13ec iter ct.1.6: wire validator into load_workspace; refresh kind-mismatch test 2026-05-11 01:42:45 +02:00
Brummel d3280e9adf iter ct.1.5: migrate bare cross-module type refs in examples/ 2026-05-11 01:40:20 +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 a73f7d3213 iter ct.1.4-followup: type-con rewrite test + doc clarity 2026-05-11 01:21:18 +02:00
Brummel d45977f9bb iter ct.1.4: dev-only ail migrate-canonical-types subcommand 2026-05-11 01:16:55 +02:00
Brummel 219908ed54 iter ct.1.3-followup: test for Constraint.class in ClassDef-method Forall 2026-05-11 01:11:47 +02:00
Brummel 9e2e84332f iter ct.1.3: validator rejects qualified class-name fields 2026-05-11 01:08:50 +02:00
Brummel 3723495d8a iter ct.1.2: validator extends to Term::Ctor.type_name 2026-05-11 01:04:39 +02:00
Brummel 000b84dda7 iter ct.1.1: validator scaffolding + Type::Con canonical-form rules
Adds BareCrossModuleTypeRef / BadCrossModuleTypeRef / QualifiedClassName
to WorkspaceLoadError plus the validate_canonical_type_names function
that enforces the canonical-form rule on every Type::Con name reachable
from any def (including Term::Lam.param_tys / .ret_ty and Term::LetRec.ty).
Term::Ctor.type_name and class-name fields land in Tasks 2 + 3; the
validator is not yet wired into load_workspace (Task 6). Seven RED-first
unit tests cover the cases enumerated in spec section Testing strategy
plus a Lam-embedded-type smuggle-prevention test.

main.rs gains diagnostic arms for the three new variants to keep the
exhaustive match compiling.
2026-05-11 00:58:37 +02:00
Brummel 7ee4300ae2 plan: ct.1 canonical type names — validator + migration 2026-05-11 00:53:07 +02:00
Brummel 949785c3aa spec: canonical type names — step-7 cleanup (header, migration disambig, drop stale history note) 2026-05-11 00:39:42 +02:00
Brummel 8068be27a1 roadmap: P2 milestone — module-qualified class names + type-driven method dispatch 2026-05-11 00:36:15 +02:00
Brummel 33932cb6e6 spec: canonical type names — name MethodNameCollision as the workaround it is 2026-05-11 00:33:57 +02:00
Brummel b840c340d4 spec: canonical type names — class-names out-of-scope rationale 2026-05-11 00:28:39 +02:00
Brummel 4d614a053f spec: revise canonical type names — module-scoped, bare=local 2026-05-11 00:22:28 +02:00
Brummel 72d719010c spec: revise canonical type names — AST is context-free 2026-05-11 00:11:39 +02:00
Brummel b6a84041eb spec: canonical type names — internal qualification 2026-05-10 23:55:05 +02:00
Brummel 12d9130567 iter 23.3.3: prelude — class Ord a extends Eq + Ord Int/Bool/Str instances 2026-05-10 23:13:02 +02:00
Brummel 119632812d iter 23.3.2-fixup: emit_compare_ladder helper + drop unused test param 2026-05-10 23:10:02 +02:00
Brummel d865f8a618 iter 23.3.2: codegen — three compare__T intercept arms + emit_ordering_arm helper 2026-05-10 23:05:45 +02:00
Brummel 94893bfb9d iter 23.3.1: runtime ail_str_compare + IR header declaration 2026-05-10 23:00:22 +02:00
Brummel 2c974e3c7e plan: 23.3 Ord class + primitive instances (compare__Int/Bool/Str) 2026-05-10 22:57:54 +02:00
Brummel 24f900194f iter 23.2.5: journal entry — Eq class + primitive instances 2026-05-10 22:51:29 +02:00
Brummel a11cb2f144 iter 23.2.4-fixup: symmetrize check_workspace error assertion across three IR-shape tests 2026-05-10 22:50:00 +02:00
Brummel 559e591ab2 iter 23.2.4: e2e smoke fixture + ir-shape integration tests for eq__T mono symbols 2026-05-10 22:46:51 +02:00
Brummel be882c4ef8 fix: codegen lower_workspace_inner implicit prelude import (4th lockstep site) 2026-05-10 22:44:37 +02:00
Brummel 7172e7e8c9 iter 23.2.3: prelude — class Eq a + Eq Int/Bool/Str instances 2026-05-10 22:35:51 +02:00
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