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

Fixes SyntaxError position with flow optional type #65

Merged
merged 1 commit into from
Aug 16, 2016
Merged

Fixes SyntaxError position with flow optional type #65

merged 1 commit into from
Aug 16, 2016

Conversation

danez
Copy link
Member

@danez danez commented Jul 3, 2016

After #19 was merged the column that babylon reports for SyntaxErrors involving a question mark was slightly off, because the initial SyntaxError was swallowed, a backtrack performed and then a new SyntaxError generated. For example:

var a = (o ? p : =)

babylon without flow reports the = as unexpected, whereas with flow plugin it reports p as unexpected token.

This PR fixes that by forwarding the position.

@@ -551,7 +551,7 @@ pp.parseParenAndDistinguishExpression = function (startPos, startLoc, canBeArrow
if (first) {
first = false;
} else {
this.expect(tt.comma);
this.expect(tt.comma, refNeedsArrowPos.start || null);
Copy link
Member

Choose a reason for hiding this comment

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

is this just 0 b/c there's let refNeedsArrowPos = { start: 0 }; at 550?

Copy link
Member Author

@danez danez Jul 7, 2016

Choose a reason for hiding this comment

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

This line is first triggered in the second iteration if (first) ... and refNeedsArrowPos is supplied to parseMaybeAssign on line 567 and this function might be changed it there.

@codecov-io
Copy link

codecov-io commented Jul 28, 2016

Current coverage is 96.93% (diff: 100%)

Merging #65 into master will increase coverage by 0.01%

@@             master        #65   diff @@
==========================================
  Files            19         19          
  Lines          2922       2941    +19   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           2832       2851    +19   
  Misses           90         90          
  Partials          0          0          

Powered by Codecov. Last update f576865...8b9e8ec

@sebmck sebmck merged commit 4af484b into babel:master Aug 16, 2016
@danez danez deleted the fix-syntax-error-pos branch August 18, 2016 20:58
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