This repository has been archived by the owner. It is now read-only.

Fixes SyntaxError position with flow optional type #65

Merged
merged 1 commit into from Aug 16, 2016

Conversation

Projects
None yet
4 participants
@danez
Copy link
Member

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.

@danez danez added the Tag: Bug Fix label Jul 3, 2016

@danez danez force-pushed the danez:fix-syntax-error-pos branch from 27738fa to 89294f0 Jul 5, 2016

@@ -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);

This comment has been minimized.

@hzoo

hzoo Jul 6, 2016

Member

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

This comment has been minimized.

@danez

danez Jul 7, 2016

Author Member

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.

@danez danez force-pushed the danez:fix-syntax-error-pos branch from 89294f0 to 64ca55c Jul 28, 2016

@codecov-io

This comment has been minimized.

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

@kittens kittens merged commit 4af484b into babel:master Aug 16, 2016

3 checks passed

codecov/patch 100% of diff hit (target 96.91%)
Details
codecov/project 96.93% (+0.01%) compared to f576865
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@hzoo hzoo referenced this pull request Aug 16, 2016

Merged

Update CHANGELOG.md for 6.9.0 #91

@danez danez deleted the danez:fix-syntax-error-pos branch Aug 18, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.