diff --git a/crates/perry-codegen/src/expr/this_super_call.rs b/crates/perry-codegen/src/expr/this_super_call.rs index 7fccc034570..e9fdfecf2bb 100644 --- a/crates/perry-codegen/src/expr/this_super_call.rs +++ b/crates/perry-codegen/src/expr/this_super_call.rs @@ -289,6 +289,7 @@ pub(crate) fn lower(ctx: &mut FnCtx<'_>, expr: &Expr) -> Result { } } let node_stream_kind = match parent_name.as_str() { + "Readable" => Some("readable"), "Writable" => Some("writable"), "Duplex" => Some("duplex"), "Transform" => Some("transform"), @@ -336,6 +337,7 @@ pub(crate) fn lower(ctx: &mut FnCtx<'_>, expr: &Expr) -> Result { } let node_stream_kind = match parent_name.as_str() { "Readable" => Some("readable"), + "Writable" => Some("writable"), "Duplex" => Some("duplex"), "Transform" => Some("transform"), _ => None, diff --git a/crates/perry-hir/src/lower_decl/class_decl.rs b/crates/perry-hir/src/lower_decl/class_decl.rs index 6a718d3beee..4d319bb5f6c 100644 --- a/crates/perry-hir/src/lower_decl/class_decl.rs +++ b/crates/perry-hir/src/lower_decl/class_decl.rs @@ -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() { @@ -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() {