Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/perry-codegen/src/expr/this_super_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ pub(crate) fn lower(ctx: &mut FnCtx<'_>, expr: &Expr) -> Result<String> {
}
}
let node_stream_kind = match parent_name.as_str() {
"Readable" => Some("readable"),
"Writable" => Some("writable"),
"Duplex" => Some("duplex"),
"Transform" => Some("transform"),
Expand Down Expand Up @@ -336,6 +337,7 @@ pub(crate) fn lower(ctx: &mut FnCtx<'_>, expr: &Expr) -> Result<String> {
}
let node_stream_kind = match parent_name.as_str() {
"Readable" => Some("readable"),
"Writable" => Some("writable"),
"Duplex" => Some("duplex"),
"Transform" => Some("transform"),
_ => None,
Expand Down
21 changes: 21 additions & 0 deletions crates/perry-hir/src/lower_decl/class_decl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,21 @@ pub fn lower_class_decl(
"transform_stream".to_string(),
"TransformStream".to_string(),
)),
// #1545: classic node:stream base classes. Recognising them
// as native parents (rather than letting the unknown-Ident
// arm capture `extends_expr`) avoids the dynamic
// parent-registration throw ("Class extends value is not a
// constructor") — a node:stream export is a callable but not
// a registered class constructor. The `super(opts)` codegen
// arm (`lower_node_stream_super_init`) and the runtime
// `js_node_stream_*_subclass_init` helpers, which install the
// native stream methods directly onto `this`, were already
// built; this is the missing HIR wiring. Keep in lockstep
// with the parallel arm in `lower_class_from_ast` below.
"Readable" => Some(("node_stream".to_string(), "Readable".to_string())),
"Writable" => Some(("node_stream".to_string(), "Writable".to_string())),
"Duplex" => Some(("node_stream".to_string(), "Duplex".to_string())),
"Transform" => Some(("node_stream".to_string(), "Transform".to_string())),
_ => None,
};
if native_parent.is_some() {
Expand Down Expand Up @@ -1215,6 +1230,12 @@ pub fn lower_class_from_ast(
"transform_stream".to_string(),
"TransformStream".to_string(),
)),
// #1545: classic node:stream base classes — keep in lockstep
// with the parallel arm in `lower_class_decl` above.
"Readable" => Some(("node_stream".to_string(), "Readable".to_string())),
"Writable" => Some(("node_stream".to_string(), "Writable".to_string())),
"Duplex" => Some(("node_stream".to_string(), "Duplex".to_string())),
"Transform" => Some(("node_stream".to_string(), "Transform".to_string())),
_ => None,
};
if native_parent.is_some() {
Expand Down