Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Fix accidental fall-through in Flow type parsing. #82

Merged
merged 1 commit into from
Jul 28, 2016

Conversation

xiemaisi
Copy link
Contributor

When parsing a primary type, > would erroneously be treated like (. For example, >x:int) => string was parsed the same as (x:int) => string.

@@ -505,6 +505,8 @@ pp.flowParsePrimaryType = function () {
node.returnType = this.flowParseType();

return this.finishNode(node, "FunctionTypeAnnotation");
} else {
this.unexpected();
Copy link
Member

Choose a reason for hiding this comment

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

This is just minor and makes not a big difference, but maybe adding here just a break and then it would call this.unexpected() on line 395

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, that works, too. I've amended the commit.

@danez
Copy link
Member

danez commented Jul 26, 2016

Good catch. I wonder if we have the same problem with tt.plusMin

@codecov-io
Copy link

codecov-io commented Jul 26, 2016

Current coverage is 96.91% (diff: 100%)

Merging #82 into master will increase coverage by <.01%

@@             master        #82   diff @@
==========================================
  Files            19         19          
  Lines          2913       2914     +1   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           2823       2824     +1   
  Misses           90         90          
  Partials          0          0          

Powered by Codecov. Last update 88d7e20...39cee24

@xiemaisi
Copy link
Contributor Author

That certainly also looks suspicious, but I wasn't immediately able to construct an example (I'm new to Babylon).

When parsing a primary type, `>` would erroneously be treated like `(`.
@danez
Copy link
Member

danez commented Jul 26, 2016

Yes I also couldn't figure out an example.
Thanks

@danez danez merged commit fd18d89 into babel:master Jul 28, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants