Skip to content

Dynamic function name causes no symbol returned #33604

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
octref opened this issue Sep 25, 2019 · 3 comments
Closed

Dynamic function name causes no symbol returned #33604

octref opened this issue Sep 25, 2019 · 3 comments
Assignees
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Bug A bug in TypeScript

Comments

@octref
Copy link

octref commented Sep 25, 2019

TypeScript Version: 3.7.0-dev.20190924

Search Terms:

  • dynamic function name

Code

function createTimesFunction(factor){
	const name='times_'+factor;
	return {[name]: function(x){return x*factor;} }[name];
}

Expected behavior:
TS Server returns symbol createTimesFunction

Actual behavior:
TS Server fails with below stacks trace:

[Error - 17:34:36] Error while computing document symbols for file:///my/path/to/index.html: Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
    at Object.unescapeLeadingUnderscores (d:\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\typescript.js:13211:19)
    at tryGetName (d:\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\typescript.js:105875:27)
    at compareChildren (d:\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\typescript.js:105861:78)
    at Array.sort (native)
    at sortChildren (d:\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\typescript.js:105858:22)
    at endNode (d:\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\typescript.js:105614:17)
    at addNodeWithRecursiveChild (d:\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\typescript.js:105621:13)
    at addChildrenRecursively (d:\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\typescript.js:105704:21)
    at rootNavigationBarNode (d:\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\typescript.js:105580:17)
    at Object.getNavigationBarItems (d:\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\typescript.js:105535:45)

Playground Link:

N/A. TS compiles this fine but TS Server fails.

Related Issues: Nope.

Ref: microsoft/vscode#78658

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Sep 26, 2019
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.7.0 milestone Sep 26, 2019
@RyanCavanaugh
Copy link
Member

Thanks for the nice repro with call stack!

@elibarzilay
Copy link
Contributor

@octref: I tried it now, and it looks like it's working fine with show-all-symbols and with completions. Can you try it again please?

@elibarzilay elibarzilay added the Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature label Mar 20, 2020
@octref
Copy link
Author

octref commented Mar 20, 2020

Indeed this seems to be fixed. Thanks for letting me know!

@octref octref closed this as completed Mar 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants