Skip to content

[codex] fix generator function constructor lookups#4273

Draft
andrewtdiz wants to merge 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-generator-intrinsic-constructor
Draft

[codex] fix generator function constructor lookups#4273
andrewtdiz wants to merge 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-generator-intrinsic-constructor

Conversation

@andrewtdiz
Copy link
Copy Markdown
Contributor

Summary

  • route early closure property reads for generator functions through the generator constructor/prototype helpers
  • make g.constructor resolve via the %Generator% / %AsyncGenerator% prototype's constructor property, matching Object.getPrototypeOf(g).constructor

Root Cause

js_object_get_field_by_name had an early is_closure_ptr fast path that returned undefined for constructor/prototype before the later GC_TYPE_CLOSURE branch could apply the existing generator intrinsic handling. That made g.constructor.name fail even though the generator intrinsic tower and Object.getPrototypeOf(g).constructor were present.

Validation

  • cargo check -p perry-runtime
  • PERRY_NO_AUTO_OPTIMIZE=1 npm exec --yes --package=node@26 -- bash -lc 'node --version; ./run_parity_tests.sh --suite node-suite --module globals --filter generator-intrinsics'
  • PERRY_NO_AUTO_OPTIMIZE=1 npm exec --yes --package=node@26 -- bash -lc 'node --version; ./run_parity_tests.sh --suite node-suite --module globals --filter generator-prototype'
  • PERRY_NO_AUTO_OPTIMIZE=1 npm exec --yes --package=node@26 -- bash -lc 'node --version; ./run_parity_tests.sh --suite node-suite --module util --filter generator-predicates'
  • cargo fmt --all -- --check
  • git diff --check
  • ./scripts/check_file_size.sh

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.

1 participant