Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ivy ngFor wont over ride variable in scope #30677

Closed
e-davidson opened this issue May 26, 2019 · 5 comments
Closed

Ivy ngFor wont over ride variable in scope #30677

e-davidson opened this issue May 26, 2019 · 5 comments

Comments

@e-davidson
Copy link

e-davidson commented May 26, 2019

馃悶 bug report

Affected Package

The issue is caused by the new Ivy renderer.

Is this a regression?

Yes, it is working as expected when ivy isn't enabled.

Description

the variable name used for the variable in the ngFor loop can no longer be the same as the variable you're using within the ngFor from the component.

馃敩 Minimal Reproduction

using @angular/cli@8.0.0-rc.4 create a new project.
Add a property to the AppComponent someClass: any;

Add the following to the html template of the component.

<div *ngFor='let someClass of someClass.children' >

</div>

enable ivy
run ng build --aot

It doesn't matter the type of someClass. Let it be any.
It appears that ivy can't differentiate between the someClass in let someClass and someClass in someClass.children.

The code won't compile unless you change the name to something different.
Like this.

<div *ngFor='let someClass2 of someClass.children' >

</div>
https://stackblitz.com/edit/angular-eurwqh

I'm not sure how to get stack blitz to run with the --aot flag. So here's a git repo with the same code. https://github.com/e-davidson/angular-ivy-issue

馃敟 Exception or Error





ERROR in : Error: Could not resolve [object Object] / undefined
    at Scope.resolve (C:\Users\edavidson\src\temp\MatSortUpdateIssue\MatSortUpdateIssue\node_modules\@angular\compiler-cli\src\ngtsc\typecheck\src\type_check_block.js:549:23)
    at tcbResolve (C:\Users\edavidson\src\temp\MatSortUpdateIssue\MatSortUpdateIssue\node_modules\@angular\compiler-cli\src\ngtsc\typecheck\src\type_check_block.js:827:34)
    at C:\Users\edavidson\src\temp\MatSortUpdateIssue\MatSortUpdateIssue\node_modules\@angular\compiler-cli\src\ngtsc\typecheck\src\type_check_block.js:755:74
    at astToTypescript (C:\Users\edavidson\src\temp\MatSortUpdateIssue\MatSortUpdateIssue\node_modules\@angular\compiler-cli\src\ngtsc\typecheck\src\expression.js:47:24)
    at astToTypescript (C:\Users\edavidson\src\temp\MatSortUpdateIssue\MatSortUpdateIssue\node_modules\@angular\compiler-cli\src\ngtsc\typecheck\src\expression.js:59:28)
    at Object.astToTypescript (C:\Users\edavidson\src\temp\MatSortUpdateIssue\MatSortUpdateIssue\node_modules\@angular\compiler-cli\src\ngtsc\typecheck\src\expression.js:54:20)
    at tcbExpression (C:\Users\edavidson\src\temp\MatSortUpdateIssue\MatSortUpdateIssue\node_modules\@angular\compiler-cli\src\ngtsc\typecheck\src\type_check_block.js:755:29)
    at processAttribute (C:\Users\edavidson\src\temp\MatSortUpdateIssue\MatSortUpdateIssue\node_modules\@angular\compiler-cli\src\ngtsc\typecheck\src\type_check_block.js:802:28)
    at Array.forEach ()
    at tcbGetInputBindingExpressions (C:\Users\edavidson\src\temp\MatSortUpdateIssue\MatSortUpdateIssue\node_modules\@angular\compiler-cli\src\ngtsc\typecheck\src\type_check_block.js:792:30)
    at TcbDirectiveOp.execute (C:\Users\edavidson\src\temp\MatSortUpdateIssue\MatSortUpdateIssue\node_modules\@angular\compiler-cli\src\ngtsc\typecheck\src\type_check_block.js:300:28)
    at Scope.executeOp (C:\Users\edavidson\src\temp\MatSortUpdateIssue\MatSortUpdateIssue\node_modules\@angular\compiler-cli\src\ngtsc\typecheck\src\type_check_block.js:622:26)
    at Scope.render (C:\Users\edavidson\src\temp\MatSortUpdateIssue\MatSortUpdateIssue\node_modules\@angular\compiler-cli\src\ngtsc\typecheck\src\type_check_block.js:561:22)
    at Object.generateTypeCheckBlock (C:\Users\edavidson\src\temp\MatSortUpdateIssue\MatSortUpdateIssue\node_modules\@angular\compiler-cli\src\ngtsc\typecheck\src\type_check_block.js:43:37)
    at TypeCheckFile.addTypeCheckBlock (C:\Users\edavidson\src\temp\MatSortUpdateIssue\MatSortUpdateIssue\node_modules\@angular\compiler-cli\src\ngtsc\typecheck\src\type_check_file.js:47:41)
    at TypeCheckContext.addTemplate (C:\Users\edavidson\src\temp\MatSortUpdateIssue\MatSortUpdateIssue\node_modules\@angular\compiler-cli\src\ngtsc\typecheck\src\context.js:98:36)

馃實 Your Environment

Angular Version:




Angular CLI: 8.0.0-rc.4
Node: 12.3.1
OS: win32 x64
Angular: 8.0.0-rc.5
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.0-rc.4
@angular-devkit/build-angular     0.800.0-rc.4
@angular-devkit/build-optimizer   0.800.0-rc.4
@angular-devkit/build-webpack     0.800.0-rc.4
@angular-devkit/core              8.0.0-rc.4
@angular-devkit/schematics        8.0.0-rc.4
@angular/cli                      8.0.0-rc.4
@ngtools/json-schema              1.2.0
@ngtools/webpack                  8.0.0-rc.4
@schematics/angular               8.0.0-rc.4
@schematics/update                0.800.0-rc.4
ng-packagr                        5.2.0
rxjs                              6.5.2
typescript                        3.4.5
webpack                           4.30.0
@Airblader
Copy link
Contributor

I'd say this should throw an error so that developers stop shadowing names.

@JoostK
Copy link
Member

JoostK commented May 26, 2019

This may be fixed by #30669

@kara
Copy link
Contributor

kara commented Jun 3, 2019

@e-davidson Could you try again with the next release (8.1.0-beta.0)? It should have the fix in #30669

@kara kara added the freq1: low label Jun 3, 2019
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Jun 3, 2019
@e-davidson
Copy link
Author

@kara
I tried it and it is fixed.
Then you.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants