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

Already on GitHub? Sign in to your account

Fix crash with guessing return type #364

Merged

Conversation

@vovkasm
Copy link
Contributor

vovkasm commented Dec 26, 2016

Minimal sample to reproduce crash:

function noReturnDocTag() {
  const o = {};
  return { ...o };
}

Esdoc try to guess function return type when not @return tag found. When return type is Object, most times it can determine it's shape from AST. But when this object contains rest spread operator, it became compicated (for ex return { ...obj }, theorethically we can try track deeper and determine shape of obj, but for now we simple break guessing with *). In any case, this commit fixed crash with this case, because when AST node contain object with type SpreadProperty, it of course has no key.

@vovkasm
Copy link
Contributor Author

vovkasm commented Dec 29, 2016

Anyone? (If it helps, I can rebase branch to latest master)

vovkasm added 4 commits Dec 26, 2016
esdoc try to guess function return type when not `@return` tag found. When return type is Object, most times it can determine it's shape from AST. But when this object contains rest spread operator, it became compicated (for ex `return { ...obj }`, theorethically we can try track deeper and determine shape of `obj`, but for now we simple break guessing with `*`). In any case, this commit fixed crash with this case, because when AST node contain object with type `SpreadProperty`, it of course has no `key`.
@vovkasm vovkasm force-pushed the vovkasm:fix-crash-with-guessing-return-type branch from 8cbcdd7 to f187817 Jan 1, 2017
@vovkasm
Copy link
Contributor Author

vovkasm commented Jan 1, 2017

I just rebase and fixed this branch.
@h13i32maru, can you look at this, please! With this fix esdoc now can successfully parse our react-native project.

@ratson
Copy link

ratson commented Jan 1, 2017

@vovkasm I got the same problem, you can try my fork if you can not wait

@h13i32maru
Copy link
Member

h13i32maru commented Jan 2, 2017

@vovkasm Sorry for late reply 🙇
Thanks for this PR!

@h13i32maru h13i32maru merged commit 62e1668 into esdoc:master Jan 2, 2017
@h13i32maru
Copy link
Member

h13i32maru commented Jan 2, 2017

And I improved to guess object spread.
b613502

Thanks.

@h13i32maru h13i32maru mentioned this pull request Jan 2, 2017
5 of 5 tasks complete
@vovkasm
Copy link
Contributor Author

vovkasm commented Jan 2, 2017

Cool! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.