Skip to content

fix(eval): restore global var declaration checks and descriptors - #9031

Merged
proggeramlug merged 2 commits into
mainfrom
fix/release-direct-eval-global-var
Aug 29, 2026
Merged

proggeramlug merged 2 commits into
mainfrom
fix/release-direct-eval-global-var

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • route sloppy module-top eval("var …") through global declaration instantiation instead of the simple-expression shortcut
  • seed reflected Script var bindings as non-configurable properties before ordinary mirror writes
  • preserve top-level function-owned entry values and deduplicate the early global slots

Release blockers fixed

  • direct_eval_non_definable_global_var_throws no longer skips CanDeclareGlobalVar on a non-extensible global
  • direct and indirect eval preserve configurable:false when reusing an existing Script var

Validation

  • cargo fmt --all -- --check
  • cargo test -p perry-hir
  • Linux parity server: issue_5579_non_definable_global_eval — 7/7
  • Linux parity server: issue_5841_eval_global_descriptor — 6/6
  • Linux parity server: issue_5579_indirect_eval_global_completion — 8/8
  • Linux parity server: test_issue_611_globalthis.ts matches the committed expected output

Closes #5579
Closes #5841

Summary by CodeRabbit

  • Bug Fixes
    • Fixed global-script eval variable declarations on non-extensible global objects.
    • Preserved existing global property descriptors when declaring Script-level variables.
    • Ensured reflected global bindings are initialized correctly and remain synchronized.
  • Tests
    • Added coverage for global var bindings and descriptor preservation during entry-script evaluation.

@coderabbitai

coderabbitai Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c8ddfd73-e028-4e63-929b-c9990600743d

📥 Commits

Reviewing files that changed from the base of the PR and between f13e1dd and e6e274a.

📒 Files selected for processing (6)
  • changelog.d/9031-eval-global-var-declarations.md
  • crates/perry-codegen/src/codegen/entry.rs
  • crates/perry-hir/src/ir/module.rs
  • crates/perry-hir/src/lower/const_fold_fn.rs
  • crates/perry-hir/src/lower/lower_module_fn.rs
  • crates/perry-hir/tests/issue_5833_global_code_cluster.rs

📝 Walkthrough

Walkthrough

Global Script lowering now records var names for early global reflection. Sloppy global direct eval declarations use the general hoisting path, which checks global extensibility and preserves existing property descriptors. Documentation and regression coverage were updated.

Changes

Global eval declarations

Layer / File(s) Summary
Global var reflection
crates/perry-hir/src/ir/module.rs, crates/perry-hir/src/lower/lower_module_fn.rs, crates/perry-codegen/src/codegen/entry.rs, crates/perry-hir/tests/issue_5833_global_code_cluster.rs
Entry Script lowering records sorted, deduplicated var names in annexb_global_undefined_names. The codegen and IR comments describe the expanded scope. A regression test verifies the recorded binding.
Global eval hoisting
crates/perry-hir/src/lower/const_fold_fn.rs, changelog.d/9031-eval-global-var-declarations.md
Sloppy direct eval at global Script scope skips the simple assignment fold and uses declaration hoisting for global checks and descriptor preservation. The changelog records the fix.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: thehypnoo

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/release-direct-eval-global-var

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@proggeramlug
proggeramlug force-pushed the fix/release-direct-eval-global-var branch from 410df8a to e6e274a Compare August 29, 2026 10:32
@proggeramlug
proggeramlug marked this pull request as ready for review August 29, 2026 10:34
@proggeramlug
proggeramlug merged commit 14edb22 into main Aug 29, 2026
19 checks passed
@proggeramlug
proggeramlug deleted the fix/release-direct-eval-global-var branch August 29, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant