Skip to content

Commit 8f2550c

Browse files
Haofeiclaude
andcommitted
review #8: keep lowering type_kinds current-program-only (revert risky blanket ingest); document RSS-14
Investigated #8 (dependency types missing from the lowering type environment): a blanket ingest of interface_programs into type_kinds is a regression — bundled stdlib interfaces declare runtime-backed types (ProcessRequest, etc.) as plain structs, so classifying them as local user types drops the rsscript_runtime:: qualification (broke 3 lowering shape tests; parity stayed green). Reverted; the correct fix must distinguish runtime-backed stdlib types from genuine dependency types and be validated with a multi-package repro. Tracked as RSS-14. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent f27c053 commit 8f2550c

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

BUGS.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,24 @@ $BIN eval file.rss
5050
unified) and be guarded by a differential/fuzz test comparing old vs new output across many type
5151
strings — otherwise it risks silently changing which programs typecheck. That verification, not the
5252
tree itself, is the bulk of the work and the reason this stays a dedicated, separately-reviewed change.
53+
54+
### RSS-14 — [VALID · DEFERRED] — dependency-defined types not in the lowering type environment
55+
- **Source:** `crates/rsscript/src/rust_lower/lowerer.rs``RustLowerer`'s `type_kinds` map (and the
56+
`self.program.items` lookups for sum variants / fields) is built from the **current program only**;
57+
the `interface_programs` (builtin + dependency `.rssi`) are not folded in.
58+
- **Effect:** a `class`/`resource`/`struct`/`sum` declared in a *dependency* package's interface and
59+
then constructed/held/matched in the current source can typecheck against the contract but lower
60+
incorrectly, because `is_class_type`/`is_resource_type`/`field_type`/`sum_variant_fields_for_type`
61+
don't know its kind/fields. Not reproducible from a single file (`rss run` takes no `--interface`);
62+
it needs a real multi-package build.
63+
- **Why not a blanket fix:** simply ingesting every `interface_programs` `Item::Type` into `type_kinds`
64+
is **wrong** — the bundled stdlib interfaces declare *runtime-backed* types (e.g. `ProcessRequest`,
65+
which must lower as `rsscript_runtime::ProcessRequest`) as plain structs. Classifying those as local
66+
user types drops the `rsscript_runtime::` qualification and changes their lowering (verified: it
67+
breaks `rust_lowering_maps_process_request/stream/rules_config_reload` while parity stays green, i.e.
68+
a silent shape regression).
69+
- **Fix:** build a lowering type environment that ingests dependency interface types **while
70+
distinguishing runtime-backed stdlib types from genuine dependency types** (e.g. by interface
71+
origin / a runtime-binding marker), and validate with a multi-package fixture that constructs and
72+
matches a dependency-defined class/resource/sum. Deferred so this isn't rushed into a stdlib-lowering
73+
regression.

crates/rsscript/src/rust_lower/lowerer.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ impl<'a> RustLowerer<'a> {
5151
native_bindings: BTreeMap<String, String>,
5252
interface_programs: &[Program],
5353
) -> Self {
54+
// Type kinds (struct/class/resource) for `is_class_type`/`is_resource_type`,
55+
// constructor lowering, etc. Built from the current program only.
56+
//
57+
// NOTE (review #8): types declared in *dependency* interfaces are not added
58+
// here, so a class/resource/sum defined in another package and constructed
59+
// in this source can mis-lower. A blanket ingest of `interface_programs` is
60+
// *wrong*, though: the bundled stdlib interfaces declare runtime-backed
61+
// types (e.g. `ProcessRequest`, lowered as `rsscript_runtime::ProcessRequest`)
62+
// as plain structs, and classifying those as local user types reclassifies
63+
// them and drops the `rsscript_runtime::` qualification. The correct fix must
64+
// distinguish runtime-backed stdlib types from genuine dependency types and
65+
// be validated with a multi-package repro — tracked in BUGS.md (RSS-14).
5466
let type_kinds = program
5567
.items
5668
.iter()

0 commit comments

Comments
 (0)