iter rpe.1: retire per-type print effect-ops
Single iter shipping the post-milestone-24 follow-up named in
docs/specs/2026-05-14-retire-per-type-print-effects.md. After this
iter the only surviving direct-output effect-op is `io/print_str`;
all per-type print primitives are replaced by the polymorphic
`print` helper (prelude, iter 24.3).
Components:
- 92 examples/*.ail fixtures migrated (do io/print_<T> x) →
(app print x); 6 .prose.txt snapshots regenerated via `ail prose`.
- Four-site lockstep compiler deletion: crates/ailang-check/src/builtins.rs
(3 effect_ops.insert blocks + 3 list() rows + the
install_io_print_float_signature test + module + EffectOpSig
doc-comments); crates/ailang-codegen/src/lib.rs lower_app
(3 arms + lowers_io_print_float test); crates/ailang-codegen/src/synth.rs
builtin_effect_op_ret match-arm pattern. Dead `intern_string`
helper removed as a follow-up.
- Five incidental test-body migrations (ailang-check x2, ailang-core
spec_drift + design_schema_drift, ailang-surface/src/lex.rs,
ailang-prose/src/lib.rs round-trip test).
- Cat B test-harness patch: six IR-shape tests in
crates/ail/tests/e2e.rs gained a monomorphise_workspace call
before lower_workspace_with_alloc so they follow the same
pipeline as `ail build` (the home-rolled desugar+lift loop
stayed because mono's precondition is "already lifted"; mono
inserts after lift).
- Six doc-comment touch-ups (lex.rs module doc, parse.rs
diagnostic example, ail/src/main.rs x2, runtime/str.c %g anchor,
crates/ailang-core/specs/form_a.md surface-spec example).
- DESIGN.md seven-site sweep (Decision 11 example, Polymorphic
print past-tense, Heap-Str output sentence, effect-op
invocation comment, Float NaN paragraph re-anchored on
float_to_str, two "What is supported" lists).
- Three E2E test-comment polish + four IR-snapshot refresh + one
canonical-hash pin update (plan-unanticipated downstream
consequences of the corpus migration).
- bench/{check,compile_check,cross_lang}.py: all exit 0; no
ratification needed.
- Roadmap entry struck through; per-iter journal at
docs/journals/2026-05-14-iter-rpe.1.md.
Tests 564/0/3. cargo clippy and cargo doc: zero warnings.
Two upstream codegen bugs surfaced during the first BLOCKED
attempt and were fixed in separate iters before this retry:
- 1fb225e bugfix: mono cursor misalignment at poly-free-fn Var
with class-constrained Forall.
- feb9413 bugfix: print leak — propagate ret_mode through rigid
substitution + prelude Show.show ret_mode.
Known debt (carried forward for next /audit):
- Emitter.strings field is functionally dead post-iter (orphan
after intern_string removal); cycles over empty map harmlessly.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
//!
|
||||
//! This module owns the **fixed** symbol set the language ships with — the
|
||||
//! arithmetic / comparison / logical operators (`+`, `==`, `not`, ...) and
|
||||
//! the IO effect ops (`io/print_int`, ...). User code cannot define
|
||||
//! the IO effect ops (`io/print_str`). User code cannot define
|
||||
//! anything in here; conversely the typechecker treats every entry as
|
||||
//! always-in-scope without an explicit import.
|
||||
//!
|
||||
@@ -37,7 +37,7 @@ pub struct EffectOpSig {
|
||||
/// `Term::Do { args }`.
|
||||
pub params: Vec<Type>,
|
||||
/// Return type of the op. Often [`Type::unit`] for sinks like
|
||||
/// `io/print_int`.
|
||||
/// `io/print_str`.
|
||||
pub ret: Type,
|
||||
}
|
||||
|
||||
@@ -266,22 +266,6 @@ pub fn install(env: &mut crate::Env) {
|
||||
env.globals.insert("inf".into(), Type::float());
|
||||
env.globals.insert("neg_inf".into(), Type::float());
|
||||
|
||||
env.effect_ops.insert(
|
||||
"io/print_int".into(),
|
||||
EffectOpSig {
|
||||
effect: "IO".into(),
|
||||
params: vec![Type::int()],
|
||||
ret: Type::unit(),
|
||||
},
|
||||
);
|
||||
env.effect_ops.insert(
|
||||
"io/print_bool".into(),
|
||||
EffectOpSig {
|
||||
effect: "IO".into(),
|
||||
params: vec![Type::bool_()],
|
||||
ret: Type::unit(),
|
||||
},
|
||||
);
|
||||
env.effect_ops.insert(
|
||||
"io/print_str".into(),
|
||||
EffectOpSig {
|
||||
@@ -290,16 +274,6 @@ pub fn install(env: &mut crate::Env) {
|
||||
ret: Type::unit(),
|
||||
},
|
||||
);
|
||||
// Iter 22-floats.3: parallel to io/print_int|bool|str. Codegen
|
||||
// lowers via runtime C glue `@ail_print_float` in iter 4.
|
||||
env.effect_ops.insert(
|
||||
"io/print_float".into(),
|
||||
EffectOpSig {
|
||||
effect: "IO".into(),
|
||||
params: vec![Type::float()],
|
||||
ret: Type::unit(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Names of value-level built-ins (operators, `not`) — the ones that
|
||||
@@ -346,10 +320,7 @@ pub fn list() -> Vec<(&'static str, &'static str)> {
|
||||
("nan", "Float"),
|
||||
("inf", "Float"),
|
||||
("neg_inf", "Float"),
|
||||
("io/print_int", "(Int) -> Unit !IO [effect op]"),
|
||||
("io/print_bool", "(Bool) -> Unit !IO [effect op]"),
|
||||
("io/print_str", "(Str) -> Unit !IO [effect op]"),
|
||||
("io/print_float", "(Float) -> Unit !IO [effect op]"),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -590,50 +561,6 @@ mod tests {
|
||||
assert_eq!(ty_neg_inf, Type::float(), "neg_inf must type as Float");
|
||||
}
|
||||
|
||||
/// Iter 22-floats.3: `io/print_float : (Float) -> Unit !IO`.
|
||||
/// Mirrors `io/print_int|bool|str`. Codegen lowering through runtime
|
||||
/// C glue `@ail_print_float` lands in iter 4. Effects are collected
|
||||
/// in the mutable `effects` sink (mirrors the real typechecker
|
||||
/// pipeline); we assert both the return type and that `IO` was
|
||||
/// accumulated.
|
||||
#[test]
|
||||
fn install_io_print_float_signature() {
|
||||
let bits = 1.5_f64.to_bits();
|
||||
let mut env = Env::default();
|
||||
install(&mut env);
|
||||
let do_term = Term::Do {
|
||||
op: "io/print_float".into(),
|
||||
args: vec![lit_float(bits)],
|
||||
tail: false,
|
||||
};
|
||||
let mut locals: IndexMap<String, Type> = IndexMap::new();
|
||||
let mut effects: BTreeSet<String> = BTreeSet::new();
|
||||
let mut subst = Subst::default();
|
||||
let mut counter: u32 = 0;
|
||||
let mut residuals = Vec::new();
|
||||
let mut free_fn_calls = Vec::new();
|
||||
let mut warnings: Vec<crate::diagnostic::Diagnostic> = Vec::new();
|
||||
let ret = crate::synth(
|
||||
&do_term,
|
||||
&env,
|
||||
&mut locals,
|
||||
&mut effects,
|
||||
"<test>",
|
||||
&mut subst,
|
||||
&mut counter,
|
||||
&mut residuals,
|
||||
&mut free_fn_calls,
|
||||
&mut warnings,
|
||||
)
|
||||
.expect("synth");
|
||||
let ret = subst.apply(&ret);
|
||||
assert_eq!(ret, Type::unit(), "io/print_float returns Unit");
|
||||
assert!(
|
||||
effects.contains("IO"),
|
||||
"io/print_float must accumulate IO effect, got {effects:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// Iter 22-floats.3: pattern-matching on Float literals is hard-
|
||||
/// rejected at typecheck per spec line 723-735 recommendation (a).
|
||||
/// IEEE-`==` semantics make Float patterns semantically dubious
|
||||
|
||||
@@ -3879,9 +3879,11 @@ mod tests {
|
||||
},
|
||||
vec![],
|
||||
Term::Do {
|
||||
op: "io/print_int".into(),
|
||||
op: "io/print_str".into(),
|
||||
args: vec![Term::Lit {
|
||||
lit: Literal::Int { value: 1 },
|
||||
lit: Literal::Str {
|
||||
value: "hi".into(),
|
||||
},
|
||||
}],
|
||||
tail: false,
|
||||
},
|
||||
@@ -5055,8 +5057,12 @@ mod tests {
|
||||
},
|
||||
body: Term::Seq {
|
||||
lhs: Box::new(Term::Do {
|
||||
op: "io/print_int".into(),
|
||||
args: vec![Term::Var { name: "h".into() }],
|
||||
op: "io/print_str".into(),
|
||||
args: vec![Term::Lit {
|
||||
lit: Literal::Str {
|
||||
value: "x".into(),
|
||||
},
|
||||
}],
|
||||
tail: false,
|
||||
}),
|
||||
rhs: Box::new(Term::App {
|
||||
|
||||
Reference in New Issue
Block a user