Skip to content

Commit 8858ae3

Browse files
olwangclaude
andcommitted
feat(selfhost): AST producer — full parser error-recovery markers → 565/597
Replicated every malformed_*_span predicate the reference parser records, so the producer emits the same recovery markers instead of garbage nodes: - malformed-field / malformed-generic (struct), malformed-param / malformed-generic / malformed-effect (fn): emitters now emit only VALID nodes and the markers are appended after them (ast_oracle_dump order) via count helpers mirroring parse_fields / parse_params / parse_generic_params / parse_effects. - Empty type-args (`Map<, T>`) dropped, not dumped (malformed_arg_spans). - Empty call args (`f(, x)`) → `arg malformed=true` + unknown-expr. - Match arms without `=>` → malformed-arm, emitted after valid arms. - Nameless fn (`fn (…)`) → program-level malformed-declaration (section 5, last). - Control statements: `else` without `{`/`if` → malformed-if; `while {` (no cond) and `loop <cond> {` → malformed-loop; `match {` (no scrutinee) → malformed-match. Name-only params (`fn f(x)`) now emit a valid param with an empty type ref. Corpus reach: 543 -> 565 / 597 byte-exact (+22), still 0 run-failures. Floor -> 565. 42 samples green (10 new malformed fixtures). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 574f9df commit 8858ae3

12 files changed

Lines changed: 356 additions & 53 deletions

crates/rsscript/src/selfhost_parity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ const AST_SAMPLE_MIN: usize = 6;
15221522
/// Floor for `ast_parity_corpus` — the number of corpus files whose rss AST dump
15231523
/// already matches the oracle byte-for-byte. Ratchets up as the producer's
15241524
/// coverage grows; a drop signals a regression. (Full parity = files.len().)
1525-
const AST_CORPUS_PARITY_FLOOR: usize = 543;
1525+
const AST_CORPUS_PARITY_FLOOR: usize = 565;
15261526

15271527
/// Step-2 measurement gate (ignored by default): how many corpus files the rss
15281528
/// producer reproduces byte-for-byte. Not full parity yet — this ratchets a floor

selfhost/astdump.rss

Lines changed: 252 additions & 52 deletions
Large diffs are not rendered by default.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// expect: RS0015
2+
3+
fn bad_if(value: read Bool) -> Unit {
4+
if value {
5+
return Unit
6+
} else return Unit
7+
}
8+
9+
fn bad_loop() -> Unit {
10+
loop true {
11+
return Unit
12+
}
13+
}
14+
15+
fn bad_while() -> Unit {
16+
while {
17+
return Unit
18+
}
19+
}
20+
21+
fn bad_match() -> Unit {
22+
match {
23+
_ => return Unit
24+
}
25+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// expect: RS0015
2+
3+
fn main() -> Unit {
4+
Log.write(, message: read "hello")
5+
Log.write(message: read "hello",, tag: read "demo")
6+
return Unit
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// expect: RS0015
2+
fn (value: read String) -> Unit {
3+
return Unit
4+
}
5+
6+
fn main() -> Unit {
7+
return Unit
8+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// expect: RS0015
2+
3+
fn empty_effect_slot(value: read String) -> Unit
4+
effects(no_panic,, native)
5+
{
6+
return Unit
7+
}
8+
9+
fn empty_retains(value: read String) -> Unit
10+
effects(retains())
11+
{
12+
return Unit
13+
}
14+
15+
fn unknown_effect_call(value: read String) -> Unit
16+
effects(custom(value))
17+
{
18+
return Unit
19+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// expect: RS0015
2+
3+
fn bad(, path: read Path) -> Unit {
4+
return Unit
5+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// expect: RS0015
2+
struct Broken {
3+
name String
4+
value:
5+
}
6+
7+
fn main() -> Unit {
8+
return Unit
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// expect: RS0015
2+
3+
struct Box<T: Unknown> {
4+
value: handle T
5+
}
6+
7+
fn bad<read T>(value: read String) -> Unit {
8+
return Unit
9+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// expect: RS0015
2+
3+
fn bad(read Path) -> Unit {
4+
return Unit
5+
}

0 commit comments

Comments
 (0)