on master help sign in
Fix #1535, order of defs matters!

In some cases, I skipped reversing things back to their original order. In this case, the original order was important! There is already a test for this, but I guess I got excited about the new parse error messages and forgot about this case. The NonHomogeneousRecords change now matches the previous version: https://github.com/elm-lang/elm-compiler/commit/239af836ec601ce96e57ddc4 a3d8f3a01497e8cf#diff-5d834b6ba7fbbd59d5a79fcc66792e32

commit35947012e791a55e495440bf4230ee17e71798f7 authorEvan Czaplicki <evancz@users.noreply.github.com> dateSun 18 Dec 2016, 21:06 (10 years ago) parent0c6152d
3 files changed+10−4
src/Parse/Expression.hs+3−3 tests/test-files/good-expected-js/Records/NonHomogeneousRecords.elm.js+1−1 tests/test-files/good-expected-js/Soundness/IdAnnotated.elm.js+6
src/Parse/Expression.hs+3−3
@@ -489,11 +489,11 @@ let_ start =
489489
490490
491491letHelp :: R.Position -> Int -> [Src.RawDef] -> R.Position -> SPos -> ExprParser
492−letHelp start oldIndent defs end pos =
492+letHelp start oldIndent revDefs end pos =
493493 oneOf
494494 [ do checkAligned pos
495495 (def, newEnd, newPos) <- definition
496− letHelp start oldIndent (def:defs) newEnd newPos
496+ letHelp start oldIndent (def:revDefs) newEnd newPos
497497
498498 , do setIndent oldIndent
499499 checkSpace pos
@@ -501,7 +501,7 @@ letHelp start oldIndent defs end pos =
501501 popContext ()
502502 spaces
503503 (body, newEnd, newPos) <- expression
504− let letExpr = A.at start end (Src.Let defs body)
504+ let letExpr = A.at start end (Src.Let (reverse revDefs) body)
505505 return ( letExpr, newEnd, newPos )
506506 ]
507507
tests/test-files/good-expected-js/Records/NonHomogeneousRecords.elm.js+1−1
@@ -1,6 +1,6 @@
11var _elm_lang$core$Main$bindFields = function (thing) {
2− var x = thing.x;
32 var y = thing.y;
3+ var x = thing.x;
44 return thing;
55};
66var _elm_lang$core$Main$Thing = F2(
tests/test-files/good-expected-js/Soundness/IdAnnotated.elm.jsnew file+6
@@ -0,0 +1,6 @@
1+var _elm_lang$core$Main$myId = function () {
2+ var id = function (x) {
3+ return x;
4+ };
5+ return id;
6+}();