Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Ivy] angular 9 compiler Internal Error: The name <name> is already defined in scope to be [object Object]Β #35369

Closed
@djleonskennedy

Description

@djleonskennedy

🐞 bug report

Affected Package

@angular/compiler

Is this a regression?

Yes, we're migrating from 7.1.x, in 7's version no error in aot mode

Description

if we accidentally duplicate let expression in template we'll get an error

<ng-template #tmps let-obj let-obj="obj">
  {{obj | json}}
</ng-template>
<ng-container 
  [ngTemplateOutlet]="tmps" 
  [ngTemplateOutletContext]="{$implicit: {a: 2}"
</ng-container>

this is correct behavior, but during migration it's quite hard to investigate where actually error is.
Cause of error message The name <name> is already defined in scope to be [object Object]
due to [object Object] it's not understandable

Minimal Reproduction

https://github.com/djleonskennedy/ng9-repro

  • npm i
  • npm run build --prod

NOTE - issue cannot be reproduced in stackblitz

πŸ”₯ Exception or Error


ERROR in Error: Internal Error: The name obj is already defined in scope to be [object Object]
    at error (/home/project/src/santander/misc/example/node_modules/@angular/compiler/bundles/compiler.umd.js:2721:15)
    at BindingScope.set (/home/project/src/santander/misc/example/node_modules/@angular/compiler/bundles/compiler.umd.js:18154:17)
    at TemplateDefinitionBuilder.registerContextVariables (/home/project/src/santander/misc/example/node_modules/@angular/compiler/bundles/compiler.umd.js:17051:32)
    at /home/project/src/santander/misc/example/node_modules/@angular/compiler/bundles/compiler.umd.js:16967:59
    at Array.forEach ()
    at TemplateDefinitionBuilder.buildTemplateFunction (/home/project/src/santander/misc/example/node_modules/@angular/compiler/bundles/compiler.umd.js:16967:23)
    at /home/project/src/santander/misc/example/node_modules/@angular/compiler/bundles/compiler.umd.js:17558:60
    at /home/project/src/santander/misc/example/node_modules/@angular/compiler/bundles/compiler.umd.js:16992:81
    at Array.forEach ()
    at TemplateDefinitionBuilder.buildTemplateFunction (/home/project/src/santander/misc/example/node_modules/@angular/compiler/bundles/compiler.umd.js:16992:37)
    at Object.compileComponentFromMetadata (/home/project/src/santander/misc/example/node_modules/@angular/compiler/bundles/compiler.umd.js:18643:58)
    at ComponentDecoratorHandler.compile (/home/project/src/santander/misc/example/node_modules/@angular/compiler-cli/src/ngtsc/annotations/src/component.js:534:34)
    at _loop_2 (/home/project/src/santander/misc/example/node_modules/@angular/compiler-cli/src/ngtsc/transform/src/compilation.js:542:53)
    at TraitCompiler.compile (/home/project/src/santander/misc/example/node_modules/@angular/compiler-cli/src/ngtsc/transform/src/compilation.js:572:21)
    at IvyVisitor.visitClassDeclaration (/home/project/src/santander/misc/example/node_modules/@angular/compiler-cli/src/ngtsc/transform/src/transform.js:51:40)
    at /home/project/src/santander/misc/example/node_modules/@angular/compiler-cli/src/ngtsc/util/src/visitor.js:77:93

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `ng build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/yuriy_yakovenko/.npm/_logs/2020-02-12T10_41_09_828Z-debug.log

🌍 Your Environment

Angular Version:


Angular CLI: 9.0.1
Node: 12.13.1
OS: linux x64

Angular: 9.0.0
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, material, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.1
@angular-devkit/build-angular     0.900.1
@angular-devkit/build-optimizer   0.900.1
@angular-devkit/build-webpack     0.900.1
@angular-devkit/core              9.0.1
@angular-devkit/schematics        9.0.1
@angular/cli                      9.0.1
@ngtools/webpack                  9.0.1
@schematics/angular               9.0.1
@schematics/update                0.900.1
rxjs                              6.5.4
typescript                        3.7.5
webpack                           4.41.2

Anything else relevant?
Could be related: angular/angular-cli#14663

Regards Yuriy!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions