Skip to content

Commit c9a01af

Browse files
committed
Lexical "this" capture
1 parent c7f8e59 commit c9a01af

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

packages/@glimmer/syntax/lib/v2/builders.ts

-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ export class Builder {
208208
isTemplateLocal: boolean,
209209
loc: SourceSpan
210210
): ASTv2.VariableReference {
211-
assert(name !== 'this', `You called builders.var() with 'this'. Call builders.this instead`);
212211
assert(
213212
name[0] !== '@',
214213
`You called builders.var() with '${name}'. Call builders.at('${name}') instead`

packages/@glimmer/syntax/lib/v2/normalize.ts

+4
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@ class ExpressionNormalizer {
323323

324324
switch (head.type) {
325325
case 'ThisHead':
326+
if (block.hasBinding('this')) {
327+
let [symbol, isRoot] = table.get('this');
328+
return block.builder.localVar('this', symbol, isRoot, offsets);
329+
}
326330
return builder.self(offsets);
327331
case 'AtHead': {
328332
let symbol = table.allocateNamed(head.name);

0 commit comments

Comments
 (0)