What happened
Single module fails compilation with an internal-codegen error from the string self-append fast-path:
Error compiling module 'node_modules/effect/src/internal/channel.ts': lowering closure func_id=263:
lowering closure body func_id=263: string self-append: local 441 not in scope
The error message comes from crates/perry-codegen/src/lower_string_method.rs (or wherever the s += t self-append optimization lives). The HIR transform that hoists or rebinds locals is producing a LocalGet(441) that the codegen-side scope lookup can't resolve.
What you expected
The lowering should either resolve the local through the same mechanism LocalGet uses everywhere else, or fall through to the slow path s = s + t when the optimization can't safely apply.
Why this is happening
Likely the same class as #318 (closure-collector misses arms): a HIR transform pass (closure-capture rewrite, generator transform, async-to-generator, inliner) is renumbering or hoisting locals, and the string self-append fast-path's scope lookup is the wrong walker — i.e. it's looking at the closure's own locals but the rewritten id lives in a parent / sibling scope.
Likely fix site
crates/perry-codegen/src/lower_string_method.rs — search for "string self-append". The fast path likely has its own ad-hoc scope-resolution logic that needs to consult the same scope chain LocalGet uses. Safe interim: when the scope lookup fails, fall through to the generic s = s + t slow path with an internal-warn trace rather than aborting compile.
Minimal reproduction
Same scratch project as #309. Single isolated repro is non-trivial — internal/channel.ts is a 1500+ LOC module and func 263 is one of many. The right approach is probably to land #318 first (which is the broader walker class) and see if this error persists; if it does, file a focused TS repro then.
Environment
- Perry version: 0.5.405
- Host OS: macOS 26.4 (arm64)
- Target: native
- Effect version: 3.21.2 (where this surfaced)
Discovered as part of the #309 long tail.
What happened
Single module fails compilation with an internal-codegen error from the string self-append fast-path:
The error message comes from
crates/perry-codegen/src/lower_string_method.rs(or wherever thes += tself-append optimization lives). The HIR transform that hoists or rebinds locals is producing aLocalGet(441)that the codegen-side scope lookup can't resolve.What you expected
The lowering should either resolve the local through the same mechanism
LocalGetuses everywhere else, or fall through to the slow paths = s + twhen the optimization can't safely apply.Why this is happening
Likely the same class as #318 (closure-collector misses arms): a HIR transform pass (closure-capture rewrite, generator transform, async-to-generator, inliner) is renumbering or hoisting locals, and the string self-append fast-path's scope lookup is the wrong walker — i.e. it's looking at the closure's own locals but the rewritten id lives in a parent / sibling scope.
Likely fix site
crates/perry-codegen/src/lower_string_method.rs— search for"string self-append". The fast path likely has its own ad-hoc scope-resolution logic that needs to consult the same scope chainLocalGetuses. Safe interim: when the scope lookup fails, fall through to the generics = s + tslow path with an internal-warn trace rather than aborting compile.Minimal reproduction
Same scratch project as #309. Single isolated repro is non-trivial —
internal/channel.tsis a 1500+ LOC module and func 263 is one of many. The right approach is probably to land #318 first (which is the broader walker class) and see if this error persists; if it does, file a focused TS repro then.Environment
Discovered as part of the #309 long tail.