Fix crash with guessing return type #364

Merged
merged 4 commits into from Jan 2, 2017

Conversation

Projects
None yet
3 participants
@vovkasm
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

This comment has been minimized.

Show comment
Hide comment
@vovkasm

vovkasm Dec 29, 2016

Contributor

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

Contributor

vovkasm commented Dec 29, 2016

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

vovkasm added some commits Dec 26, 2016

Fix crash when guessing function return types.
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

This comment has been minimized.

Show comment
Hide comment
@vovkasm

vovkasm Jan 1, 2017

Contributor

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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@ratson

ratson Jan 1, 2017

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

ratson commented Jan 1, 2017

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

@h13i32maru

This comment has been minimized.

Show comment
Hide comment
@h13i32maru

h13i32maru Jan 2, 2017

Member

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

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

This comment has been minimized.

Show comment
Hide comment
@h13i32maru

h13i32maru Jan 2, 2017

Member

And I improved to guess object spread.
b613502

Thanks.

Member

h13i32maru commented Jan 2, 2017

And I improved to guess object spread.
b613502

Thanks.

@h13i32maru h13i32maru referenced this pull request Jan 2, 2017

Closed

ES7 objectRestSpread bug #365

5 of 5 tasks complete
@vovkasm

This comment has been minimized.

Show comment
Hide comment
@vovkasm

vovkasm Jan 2, 2017

Contributor

Cool! Thank you!

Contributor

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