Commit Graph

214 Commits

Author SHA1 Message Date
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 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 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 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 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 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 ea8988b529 floats iter 5.1: prose renders Float literals (finite + NaN/Inf) 2026-05-10 16:36:12 +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 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 c619697a76 floats iter 2.3: surface print emits shortest round-trippable decimal with .0 fallback 2026-05-10 15:11:31 +02:00
Brummel f62bff08a3 floats iter 2.2: parser accepts Tok::Float in term and pat-lit positions 2026-05-10 15:07:39 +02:00
Brummel f960e39f8b floats iter 2.1 fixup: drop task-tags + refresh stale prose + uppercase-E + leading-dot tests 2026-05-10 15:04:50 +02:00
Brummel d0c9133ae4 floats iter 2.1: Tok::Float + LexError::InvalidFloat + spec-A2 grammar validator 2026-05-10 15:00:46 +02:00
Brummel b2d31824a1 floats iter 1.4 fixup: drop intra-doc-links to private hex_u64 (rustdoc baseline preservation) 2026-05-10 14:49:21 +02:00
Brummel 1a4e2f04b7 floats iter 1.4: refresh canonical.rs 'no floats' doc comment 2026-05-10 14:47:43 +02:00
Brummel 7c95a69780 floats iter 1.3: bit-stability tests for Literal::Float 2026-05-10 14:45:34 +02:00
Brummel 93bae2d02a floats iter 1.2 fixup: replace iter-N comment with durable rationale for explicit assertions 2026-05-10 14:44:14 +02:00
Brummel aa5b88e8d4 floats iter 1.2: register Float as a primitive type name 2026-05-10 14:42:23 +02:00