Skip to content

Remove hard-linked AST body in function pointers. - #1114

Merged
schungx merged 7 commits into
rhaiscript:mainfrom
schungx:master
Aug 10, 2026
Merged

Remove hard-linked AST body in function pointers.#1114
schungx merged 7 commits into
rhaiscript:mainfrom
schungx:master

Conversation

@schungx

@schungx schungx commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Hard linking a closure's AST function body into the FnPtr type causes two issues:

  • The closure body can no longer be optimized. The optimizer actually clones the AST body and optimizes it, but that optimized AST body is never called because Rhai would use the hard-linked non-optimized version instead!

  • This causes a discrepancy between the AST walker and the Rhai Grain VM (which cannot interpret an AST and thus must go through the normal function resolution procecss).

After this PR, the discrepancy between Rhai AST and Rhai Grain is eliminated. The CI test a_folded_closure_body_keeps_the_optimizers_answer is also removed.

In addition, this PR also fine tunes some inline docs and README entries for the added Rhai Grain stuff.

@schungx schungx changed the title Remove hard linked AST body in function pointers. Remove hard-linked AST body in function pointers. Aug 10, 2026
@schungx
schungx merged commit ef09bc5 into rhaiscript:main Aug 10, 2026
51 checks passed
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