Skip to content

[codex] Fix native instance walk for fluent chains#4219

Merged
proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/fix-opencode-compile-timeout
Jun 3, 2026
Merged

[codex] Fix native instance walk for fluent chains#4219
proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/fix-opencode-compile-timeout

Conversation

@andrewtdiz
Copy link
Copy Markdown
Contributor

Summary

Fixes the local native-instance rewrite pass so non-native fluent call chains are walked linearly instead of revisiting the same property receiver at every chain level.

The OpenCode/Perry graph previously reached module collection/tree-shake and then timed out in run_native_instance_fixups while processing the long yargs chain in the OpenCode overlay src/index.ts. The Cheerio chained-call special case recursively fixed a property receiver, then the generic fallback walked the whole callee again, making long non-native fluent chains exponential.

Changes

  • Tracks when the property receiver has already been recursively fixed in fix_native_instance_expr_with_locals.
  • Skips the duplicate generic callee recursion in that case while still visiting call arguments.
  • Adds a regression that constructs a non-native fluent HIR chain directly and runs fix_local_native_instances over it.

Validation

  • cargo test -p perry-hir --test cheerio_call_rewrite -> 2 passed; 0 failed.
  • cargo build --release -p perry -> finished release build.
  • Direct OpenCode compile repro with the fixed release binary moved past the previous native-fixup timeout, reached Found 2760 module(s): 2760 native, 0 JavaScript, entered Generating code..., then hit the next compiler blocker: thread '<unknown>' has overflowed its stack during codegen.
  • OpenTUI harness with the fixed release binary also moved past native-fixup and failed at the next codegen stack overflow. Kept temp dir: /var/folders/8q/vx4z9tqd08jd1b5_bykzbdkr0000gn/T/opentui-perry-native-Irv8KZ.

Notes

This does not complete the OpenTUI/OpenCode Perry-native migration. It only moves the fluent-chain/native-fixup timeout blocker; the next blocker is a Perry codegen stack overflow before a binary is produced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants