Skip to content

Add resolveAliasAsValue to fix a stack overflow#3141

Closed
JsonFreeman wants to merge 1 commit into
masterfrom
resolveAliasAsValue
Closed

Add resolveAliasAsValue to fix a stack overflow#3141
JsonFreeman wants to merge 1 commit into
masterfrom
resolveAliasAsValue

Conversation

@JsonFreeman
Copy link
Copy Markdown
Contributor

Fixes #2933. The issue is that getTypeOfAlias needs to resolve the alias as a value, which would cause resolveAlias to detect a cycle. However, resolveAlias has no idea that it's looking for a value, so it stops early. This causes getTypeOfAlias to infinitely recurse, and each time it calls resolveAlias, it gets back an alias that is its own target.

The fix is to make a more aggressive resolveAliasAsValue, which will detect the cycle properly. And getTypeOfAlias should call that.

For a more complete explanation, see #3140.

Comment thread src/compiler/types.ts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't like comments like this when they're too long for single line. I'd just put the comment on top of the actual item itself. (nit).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I put it above and changed it to a doc comment

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

Does htis only repro for LS scenarios? Is there a command line exampe that would hit this?

@JsonFreeman
Copy link
Copy Markdown
Contributor Author

I wasn't able to find any command line scenarios for this. I feel like it should be possible to hit in theory, but it's possible the code paths required are not reachable from the command line.

@JsonFreeman
Copy link
Copy Markdown
Contributor Author

Closing in favor of #3160

@JsonFreeman JsonFreeman deleted the resolveAliasAsValue branch May 14, 2015 00:50
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stack overflow when getting quickinfo on alias with same name as module

3 participants