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

injector.get() returns undefined instead of default value #27729

Closed
thekiba opened this issue Dec 18, 2018 · 6 comments

Comments

@thekiba
Copy link
Contributor

commented Dec 18, 2018

馃悶 bug report

Affected Package

The issue is caused by package @angular/core

Is this a regression?

Yes, the previous version in which this bug was not present was: @angular/core@6.0.0-beta.3

Description

injector.get() returns undefined instead of the default value if such a token is not found and InjectFlag.Self is added.

馃敩 Minimal Reproduction

https://stackblitz.com/edit/angular-injector-bug-with-default-value-and-self-flag?file=index.ts

馃敟 Exception or Error





馃實 Your Environment

Angular Version:




     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / 鈻 \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 7.1.3
Node: 11.4.0
OS: darwin x64
Angular: 7.1.3
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.11.3
@angular-devkit/build-angular      0.11.3
@angular-devkit/build-ng-packagr   0.11.3
@angular-devkit/build-optimizer    0.11.3
@angular-devkit/build-webpack      0.11.3
@angular-devkit/core               7.1.3
@angular-devkit/schematics         7.1.3
@angular/cdk                       7.1.0
@ngtools/json-schema               1.1.0
@ngtools/webpack                   7.1.3
@schematics/angular                7.1.3
@schematics/update                 0.11.3
ng-packagr                         4.4.5
rxjs                               6.3.3
typescript                         3.1.6
webpack                            4.23.1

Anything else relevant?

@pkozlowski-opensource

This comment has been minimized.

Copy link
Member

commented Dec 18, 2018

Ha, an interesting one! This behaviour is surprising since InjectFlags.Self only makes sense for node injectors and not for provider injectors. In other words, this flag should have no effect here - but it does as we can see in the stackblitz.

Marking it as a bug, thnx for reporting!

@pkozlowski-opensource

This comment has been minimized.

Copy link
Member

commented Dec 18, 2018

@marclaval this is probably an interesting case for the work you do in ivy.

@thekiba

This comment has been minimized.

Copy link
Contributor Author

commented Dec 18, 2018

@pkozlowski-opensource, can i try fix bug by myself?

@pkozlowski-opensource

This comment has been minimized.

Copy link
Member

commented Dec 18, 2018

@thekiba you can definitely work towards sending us a PR, this would be much appreciated! Thank you for taking time to report issues and willingness to help solving them!.

thekiba added a commit to thekiba/angular that referenced this issue Dec 18, 2018
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Dec 18, 2018
thekiba added a commit to thekiba/angular that referenced this issue Dec 20, 2018
mhevery added a commit to thekiba/angular that referenced this issue Jan 15, 2019
thekiba added a commit to thekiba/angular that referenced this issue Mar 28, 2019
thekiba added a commit to thekiba/angular that referenced this issue Apr 10, 2019
thekiba added a commit to thekiba/angular that referenced this issue Apr 10, 2019
mhevery added a commit to thekiba/angular that referenced this issue Jul 26, 2019
thekiba added a commit to thekiba/angular that referenced this issue Jul 30, 2019
thekiba added a commit to thekiba/angular that referenced this issue Jul 30, 2019
thekiba added a commit to thekiba/angular that referenced this issue Jul 30, 2019
thekiba added a commit to thekiba/angular that referenced this issue Jul 31, 2019
thekiba added a commit to thekiba/angular that referenced this issue Jul 31, 2019
thekiba added a commit to thekiba/angular that referenced this issue Jul 31, 2019
@thekiba

This comment has been minimized.

Copy link
Contributor Author

commented Sep 10, 2019

I'm still having this issue

AndrewKushnir added a commit to thekiba/angular that referenced this issue Sep 12, 2019
@kara kara closed this in 0477bfc Sep 13, 2019
arnehoek added a commit to arnehoek/angular that referenced this issue Sep 26, 2019
@angular-automatic-lock-bot

This comment has been minimized.

Copy link

commented Oct 14, 2019

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 Oct 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
You can鈥檛 perform that action at this time.