3286117605
Ships class Show a where show : (a borrow) -> Str in the prelude
plus primitive Show Int / Bool / Str / Float instances. Each
instance body is a single-application lambda invoking the
corresponding runtime primitive (int_to_str, bool_to_str,
str_clone, float_to_str) — first prelude instance bodies to call
runtime primitives directly. Float is included in Show (unlike
Eq/Ord) because textual representation is well-defined modulo the
NaN-spelling caveat at DESIGN.md §Float semantics.
The 22b typeclass test corpus is migrated preemptively: 21 fixture
files and 6 consumer files (typeclass_22b{2,3}.rs +
hash.rs ct4 pin + workspace.rs iter22b1 tests + the
instance_present.prose.txt snapshot) rename class Show / show
to class TShow / tshow, analogous to the existing TEq/TOrd
convention. Migration runs before the prelude additions so the
workspace stays green throughout.
Three new tests pin the post-mono shape: show_mono_synthesis.rs
(existence of show__Int/Bool/Str/Float as Def::Fn entries in the
prelude post-mono module), show_dispatch_pin.rs (bare show and
tshow both Step-2 singletons workspace-globally),
mono_hash_stability.rs::primitive_show_mono_symbol_hashes_stay_bit_identical
(body hashes pinned for the 4 new mono symbols).
DESIGN.md §Prelude (built-in) classes drops Show from the
deferred-features list and appends a milestone-24 paragraph
naming the class signature + the 4 instances + the body shape.
print rewire stays deferred to iter 24.3.
Tests: 552 passed (was 548 + 4 new). bench/compile_check +
bench/cross_lang exit 0. bench/check exits 1 on the recurring
noise envelope per the conservative-call lineage.
91 lines
2.3 KiB
JSON
91 lines
2.3 KiB
JSON
{
|
|
"schema": "ailang/v0",
|
|
"name": "test_22b3_shadow_class_method",
|
|
"imports": [],
|
|
"defs": [
|
|
{
|
|
"kind": "class", "name": "TShow", "param": "a",
|
|
"methods": [{
|
|
"name": "tshow",
|
|
"type": {
|
|
"k": "fn", "params": [{ "k": "var", "name": "a" }],
|
|
"ret": { "k": "con", "name": "Str" }, "effects": []
|
|
}
|
|
}]
|
|
},
|
|
{
|
|
"kind": "class", "name": "Foo", "param": "a",
|
|
"methods": [{
|
|
"name": "foo",
|
|
"type": {
|
|
"k": "fn", "params": [{ "k": "var", "name": "a" }],
|
|
"ret": { "k": "con", "name": "Str" }, "effects": []
|
|
}
|
|
}]
|
|
},
|
|
{
|
|
"kind": "instance",
|
|
"class": "TShow",
|
|
"type": { "k": "con", "name": "Int" },
|
|
"methods": [{
|
|
"name": "tshow",
|
|
"body": {
|
|
"t": "lam",
|
|
"params": ["x"],
|
|
"paramTypes": [{ "k": "var", "name": "a" }],
|
|
"retType": { "k": "con", "name": "Str" },
|
|
"body": { "t": "lit", "lit": { "kind": "str", "value": "s" } }
|
|
}
|
|
}]
|
|
},
|
|
{
|
|
"kind": "instance",
|
|
"class": "Foo",
|
|
"type": { "k": "con", "name": "Int" },
|
|
"methods": [{
|
|
"name": "foo",
|
|
"body": {
|
|
"t": "lam",
|
|
"params": ["x"],
|
|
"paramTypes": [{ "k": "var", "name": "a" }],
|
|
"retType": { "k": "con", "name": "Str" },
|
|
"body": { "t": "lit", "lit": { "kind": "str", "value": "f" } }
|
|
}
|
|
}]
|
|
},
|
|
{
|
|
"kind": "fn",
|
|
"name": "main",
|
|
"type": {
|
|
"k": "fn", "params": [], "ret": { "k": "con", "name": "Str" },
|
|
"effects": []
|
|
},
|
|
"params": [],
|
|
"body": {
|
|
"t": "let",
|
|
"name": "_t",
|
|
"value": {
|
|
"t": "app",
|
|
"fn": { "t": "var", "name": "tshow" },
|
|
"args": [{ "t": "lit", "lit": { "kind": "int", "value": 5 } }]
|
|
},
|
|
"body": {
|
|
"t": "let",
|
|
"name": "tshow",
|
|
"value": { "t": "lit", "lit": { "kind": "str", "value": "shadow" } },
|
|
"body": {
|
|
"t": "let",
|
|
"name": "_u",
|
|
"value": { "t": "var", "name": "tshow" },
|
|
"body": {
|
|
"t": "app",
|
|
"fn": { "t": "var", "name": "foo" },
|
|
"args": [{ "t": "lit", "lit": { "kind": "int", "value": 7 } }]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|