RFC#998 - {{fn}} as keyword#21299
Merged
NullVoxPopuli merged 6 commits intoemberjs:mainfrom Apr 8, 2026
Merged
Conversation
Make the `fn` helper a built-in keyword so it no longer needs to be
explicitly imported in strict-mode templates (gjs/gts).
Building on the infrastructure from RFC#997 ({{on}}), this adds `fn`
to the keywords map and extends the auto-import-builtins AST plugin
to handle SubExpression and MustacheStatement nodes. The existing `on`
rewrite logic is extracted into a shared `rewriteKeyword` helper.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
packages/@glimmer-workspace/integration-tests/test/keywords/fn-test.ts
Outdated
Show resolved
Hide resolved
Use regular functions instead of helper managers for the fn shadow tests, since only scope shadowing is being verified. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The shadowed fn must return a function since its return value is passed to the on modifier as the callback argument. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Same fix as the integration test — the shadowed fn must return a function since its return value is passed to the on modifier. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
NullVoxPopuli
previously approved these changes
Apr 7, 2026
kategengler
reviewed
Apr 7, 2026
Test fn in attribute position (e.g. <Child @callback={{fn greet "hello"}} />) to cover the MustacheStatement visitor path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add empty scope to satisfy the ExplicitTemplateOnlyOptions overload when neither eval nor component is provided. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
kategengler
approved these changes
Apr 7, 2026
This was referenced Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fnto the built-in keywords map so it no longer needs to be imported in strict-mode (gjs/gts) templatesauto-import-builtinsAST plugin to handleSubExpressionandMustacheStatementnodes forfnrewriteKeywordhelper to reduce duplication with the existingonkeyword logiconPR (RFC#997 - {{on}} as keyword #21068)Implements RFC 0998.
Test plan
fn-test.ts: fn works when explicitly in scope, works with runtime compiler, can be shadowedfn-runtime-test.ts: explicit scope, implicit scope (eval), no eval and no scope (static block)fn-as-keyword-test.gjsandfn-as-keyword-but-its-shadowed-test.gjs🤖 Generated with Claude Code