Repository navigation
Closed
Closed
Copy link
Labels
area: compilerIssues related to `ngc`, Angular's template compilercore: control flowIssues related to the built-in control flow (@if, @for, @switch)state: has PR
Milestone
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
Yes
Description
Consider the template below.
app.component.html
<!-- OK -->
<span i18n>
meow
<span *ngIf="true; else elseBlock">meow?</span>
<ng-template #elseBlock>
<span>meow!</span>
</ng-template>
</span>
<!-- Not OK -->
<span i18n>
meow
@if(true) {
<span>meow?</span>
} @else {
<span>meow!</span>
}
</span>When the @if block is inside a regular HTML element having an i18n attribute, it will abort compilation with the following error message:
✘ [ERROR] Angular compilation emit failed. [plugin angular-compiler]
TypeError: Cannot read properties of undefined (reading 'startName')
at file:///workspaces/barebones-nodejs/ng17/node_modules/@angular/compiler/fesm2022/compiler.mjs:26452:37
at Array.forEach (<anonymous>)
at I18nContext.reconcileChildContext (file:///workspaces/barebones-nodejs/ng17/node_modules/@angular/compiler/fesm2022/compiler.mjs:26451:28)
at TemplateDefinitionBuilder.i18nEnd (file:///workspaces/barebones-nodejs/ng17/node_modules/@angular/compiler/fesm2022/compiler.mjs:26948:30)
at TemplateDefinitionBuilder.buildTemplateFunction (file:///workspaces/barebones-nodejs/ng17/node_modules/@angular/compiler/fesm2022/compiler.mjs:26748:18)
at file:///workspaces/barebones-nodejs/ng17/node_modules/@angular/compiler/fesm2022/compiler.mjs:27275:50
at file:///workspaces/barebones-nodejs/ng17/node_modules/@angular/compiler/fesm2022/compiler.mjs:26729:60
at Array.forEach (<anonymous>)
at TemplateDefinitionBuilder.buildTemplateFunction (file:///workspaces/barebones-nodejs/ng17/node_modules/@angular/compiler/fesm2022/compiler.mjs:26729:33)
at compileComponentFromMetadata (file:///workspaces/barebones-nodejs/ng17/node_modules/@angular/compiler/fesm2022/compiler.mjs:28917:60)
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 17.0.0
Node: 18.18.2
Package Manager: npm 9.8.1
OS: linux x64
Angular: 17.0.2
... animations, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1700.0
@angular-devkit/build-angular 17.0.0
@angular-devkit/core 17.0.0
@angular-devkit/schematics 17.0.0
@angular/cli 17.0.0
@schematics/angular 17.0.0
rxjs 7.8.1
typescript 5.2.2
zone.js 0.14.2
Anything else?
No response
Reacted by Benny Böhm
Metadata
Metadata
Assignees
Labels
area: compilerIssues related to `ngc`, Angular's template compilercore: control flowIssues related to the built-in control flow (@if, @for, @switch)state: has PR
Activity
nyannyacha commentedon Nov 10, 2023
Looking at
TemplateDefinitionBuilder, It is looking good until drilled down to thevisitIfBlock.But here
angular/packages/compiler/src/render3/view/template.ts
Lines 1178 to 1179 in 94096c6
angular/packages/compiler/src/render3/view/template.ts
Lines 948 to 960 in 94096c6
and again here
angular/packages/compiler/src/render3/view/template.ts
Lines 287 to 288 in 94096c6
If my understanding is correct,
visitIfBlockeventually makes a child builder, and the parent builder had its i18n context, but it invoked thecreateEmbeddedTemplateFnmethod without any of the i18n meta variables.I think this could be a problem 🧐
What do you think about it? 😋
pkozlowski-opensource commentedon Nov 10, 2023
cc @crisbeto
zip-fa commentedon Nov 12, 2023
#52540
this is duplicate of my issue
fix(compiler): generate i18n instructions for blocks (#52958)
angular-automatic-lock-bot commentedon Dec 21, 2023
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
fix(compiler): generate i18n instructions for blocks (angular#52958)
fix(compiler): generate i18n instructions for blocks (angular#52958)
fix(compiler): generate i18n instructions for blocks (angular#52958)
fix(compiler): generate i18n instructions for blocks (angular#52958)