diff --git a/packages/@glimmer/syntax/lib/v2/builders.ts b/packages/@glimmer/syntax/lib/v2/builders.ts index 9683e1a21..163f1fcf5 100644 --- a/packages/@glimmer/syntax/lib/v2/builders.ts +++ b/packages/@glimmer/syntax/lib/v2/builders.ts @@ -208,7 +208,6 @@ export class Builder { isTemplateLocal: boolean, loc: SourceSpan ): ASTv2.VariableReference { - assert(name !== 'this', `You called builders.var() with 'this'. Call builders.this instead`); assert( name[0] !== '@', `You called builders.var() with '${name}'. Call builders.at('${name}') instead` diff --git a/packages/@glimmer/syntax/lib/v2/normalize.ts b/packages/@glimmer/syntax/lib/v2/normalize.ts index 741464a3a..654809340 100644 --- a/packages/@glimmer/syntax/lib/v2/normalize.ts +++ b/packages/@glimmer/syntax/lib/v2/normalize.ts @@ -323,6 +323,10 @@ class ExpressionNormalizer { switch (head.type) { case 'ThisHead': + if (block.hasBinding('this')) { + let [symbol, isRoot] = table.get('this'); + return block.builder.localVar('this', symbol, isRoot, offsets); + } return builder.self(offsets); case 'AtHead': { let symbol = table.allocateNamed(head.name);