You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Classes declared inside a TypeScript namespace are lowered incompletely: not published on the namespace object, static fields uninitialized, call-expression heritage unregistered — OpenCode v1.18.30 runtime wall (fs-util.ts) #10222
A class declared inside a TypeScript namespace block is lowered incompletely by perry-hir (crates/perry-hir/src/lower/module_decl/namespace.rs, the ast::Decl::Class arm only calls lower_class_decl + push_class_dedup), unlike a module-level class (lower/module_decl.rs ~1363, which also emits RegisterClassParentDynamic, the computed-name evaluations, the static-field init statements and decorator init):
The exported class is not a member of the namespace object: N.Plain is undefined, Object.keys(N) lists only the non-class members.
Static field initializers never run: static p = 7 reads 0 even from inside the namespace.
A call-expression heritage is not registered (class Service extends Context.Service<…>()(id) {}): inside the namespace Service.key is undefined, typeof Service.of is "undefined", and Service.of(x) throws of is not a function.
This is the current runtime wall of OpenCode v1.18.30 (tracker #10107): packages/core/src/fs-util.ts declares namespace FSUtil { export class Service extends Context.Service<Service, Interface>()("@opencode/FileSystem") {} … return Service.of({...}) }, and the FSUtil layer is built by AppRuntime for every command, so models, run, serve and the TUI all die with Error: Unexpected error / of is not a function (gdb: js_throw_type_error_not_a_function ← js_class_static_method_call ← perry_closure_opencode_packages_core_src_fs_util_ts). OpenCode has three such files (core/src/fs-util.ts, core/src/util/effect-flock.ts, core/src/ripgrep/binary.ts, six classes).
C1 inside: Plain/FromBase/FromCall ["function",0,"m","function",1,{"a":1},"function"]
C2 outside N.Plain THROW Cannot read properties of undefined (reading 'p')
C3 outside N.FromBase THROW Cannot read properties of undefined (reading 'b')
C4 outside N.FromCall THROW Cannot read properties of undefined (reading 'key')
C5 outside N.FromCall.of THROW Cannot read properties of undefined (reading 'of')
C6 keys of N ["inside","ofInside","keyInside"]
C7 inside FromCall.of THROW of is not a function
C8 inside FromCall.key undefined
A top-level class Top extends (Key as any)()("@x/Top") {} with Top.of({}) works, so this is specific to the namespace body path.
Expected
The namespace arm should lower an export class the way the module-level arm does: publish the class as a namespace member (static field / export), run its static-field initializers and computed member names in source order, register the dynamic parent (RegisterClassParentDynamic) when the heritage is not a plain identifier, and run decorator init. Non-exported classes inside the namespace must still be usable from the namespace's own functions.
Fix: PR #10231 (perry-hir namespace arm now mirrors the module-level class path: member publication in source order, static init / computed names / decorators, dynamic parent registration, qualified namespace-local class names). Verified on the build host: the repro above and the FSUtil-shaped probe print the bun output; new tests crates/perry/tests/namespace_classes.rs (4) + crates/perry-hir/tests/namespace_classes.rs; cargo test -p perry-hir 664 passed. Not covered: dotted namespace A.B {} declarations and destructured namespace exports (unused by OpenCode).
Activity
proggeramlug commentedon Sep 13, 2026
Fix: PR #10231 (perry-hir namespace arm now mirrors the module-level class path: member publication in source order, static init / computed names / decorators, dynamic parent registration, qualified namespace-local class names). Verified on the build host: the repro above and the FSUtil-shaped probe print the bun output; new tests
crates/perry/tests/namespace_classes.rs(4) +crates/perry-hir/tests/namespace_classes.rs;cargo test -p perry-hir664 passed. Not covered: dottednamespace A.B {}declarations and destructured namespace exports (unused by OpenCode).fix(hir): exported namespace functions are first-class inside the nam…
fix(hir): lower classes declared inside TypeScript namespaces complet…
fix(hir): exported namespace functions are first-class inside the nam…
proggeramlug commentedon Sep 14, 2026
Fixed by merge train 185r (#10242) at 9fda98d.