Skip to content

Commit 3f3b473

Browse files
authored
Fix build errors in master (purescript#3215)
* Fix build errors in master * fix ide tests
1 parent ce94cd9 commit 3f3b473

3 files changed

Lines changed: 26 additions & 31 deletions

File tree

src/Language/PureScript/Ide/Usage.hs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,27 +136,23 @@ applySearch module_ search =
136136
(extr, _, _, _, _) = P.everythingWithScope mempty goExpr goBinder mempty mempty
137137

138138
goExpr scope expr = case expr of
139-
P.PositionedValue sp _ (P.Var i)
139+
P.Var sp i
140140
| Just ideValue <- preview _IdeDeclValue (P.disqualify search)
141141
, P.isQualified search || not (_ideValueIdent ideValue `Set.member` scope) ->
142142
[sp | map P.runIdent i == map identifierFromIdeDeclaration search]
143-
144-
P.PositionedValue sp _ (P.Constructor name)
143+
P.Constructor sp name
145144
| Just ideDtor <- traverse (preview _IdeDeclDataConstructor) search ->
146145
[sp | name == map _ideDtorName ideDtor]
147-
P.PositionedValue sp _ (P.Op opName)
146+
P.Op sp opName
148147
| Just ideOp <- traverse (preview _IdeDeclValueOperator) search ->
149148
[sp | opName == map _ideValueOpName ideOp]
150149
_ -> []
151150

152151
goBinder _ binder = case binder of
153-
P.PositionedBinder sp _ (P.ConstructorBinder ctorName _)
152+
P.ConstructorBinder sp ctorName _
154153
| Just ideDtor <- traverse (preview _IdeDeclDataConstructor) search ->
155154
[sp | ctorName == map _ideDtorName ideDtor]
156-
P.PositionedBinder sp _ (P.OpBinder opName)
157-
| Just op <- traverse (preview _IdeDeclValueOperator) search ->
158-
[sp | opName == map _ideValueOpName op]
159-
P.PositionedBinder sp _ (P.BinaryNoParensBinder (P.OpBinder opName) _ _)
155+
P.OpBinder sp opName
160156
| Just op <- traverse (preview _IdeDeclValueOperator) search ->
161157
[sp | opName == map _ideValueOpName op]
162158
_ -> []

src/Language/PureScript/Sugar/TypeClasses/Deriving.hs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -445,13 +445,13 @@ deriveEq ss mn syns ds tyConNm = do
445445
mkEqFunction _ = internalError "mkEqFunction: expected DataDeclaration"
446446

447447
preludeConj :: Expr -> Expr -> Expr
448-
preludeConj = App . App (Var nullSourceSpan (Qualified (Just (ModuleName [ProperName "Data", ProperName "HeytingAlgebra"])) (Ident C.conj)))
448+
preludeConj = App . App (Var ss (Qualified (Just (ModuleName [ProperName "Data", ProperName "HeytingAlgebra"])) (Ident C.conj)))
449449

450450
preludeEq :: Expr -> Expr -> Expr
451-
preludeEq = App . App (Var nullSourceSpan (Qualified (Just dataEq) (Ident C.eq)))
451+
preludeEq = App . App (Var ss (Qualified (Just dataEq) (Ident C.eq)))
452452

453453
preludeEq1 :: Expr -> Expr -> Expr
454-
preludeEq1 = App . App (Var (Qualified (Just dataEq) (Ident C.eq1)))
454+
preludeEq1 = App . App (Var ss (Qualified (Just dataEq) (Ident C.eq1)))
455455

456456
addCatch :: [CaseAlternative] -> [CaseAlternative]
457457
addCatch xs
@@ -465,10 +465,10 @@ deriveEq ss mn syns ds tyConNm = do
465465
identsL <- replicateM (length tys) (freshIdent "l")
466466
identsR <- replicateM (length tys) (freshIdent "r")
467467
tys' <- mapM (replaceAllTypeSynonymsM syns) tys
468-
let tests = zipWith3 toEqTest (map (Var nullSourceSpan . Qualified Nothing) identsL) (map (Var nullSourceSpan . Qualified Nothing) identsR) tys'
468+
let tests = zipWith3 toEqTest (map (Var ss . Qualified Nothing) identsL) (map (Var ss . Qualified Nothing) identsR) tys'
469469
return $ CaseAlternative [caseBinder identsL, caseBinder identsR] (unguarded (conjAll tests))
470470
where
471-
caseBinder idents = ConstructorBinder nullSourceSpan (Qualified (Just mn) ctorName) (map (VarBinder nullSourceSpan) idents)
471+
caseBinder idents = ConstructorBinder ss (Qualified (Just mn) ctorName) (map (VarBinder ss) idents)
472472

473473
conjAll :: [Expr] -> Expr
474474
conjAll [] = Literal (BooleanLiteral True)
@@ -489,7 +489,7 @@ deriveEq1 ss =
489489
[ ValueDecl (ss, []) (Ident C.eq1) Public [] (unguarded preludeEq)]
490490
where
491491
preludeEq :: Expr
492-
preludeEq = Var (Qualified (Just dataEq) (Ident C.eq))
492+
preludeEq = Var ss (Qualified (Just dataEq) (Ident C.eq))
493493

494494
deriveOrd
495495
:: forall m
@@ -528,29 +528,29 @@ deriveOrd ss mn syns ds tyConNm = do
528528
orderingName = Qualified (Just (ModuleName [ProperName "Data", ProperName "Ordering"])) . ProperName
529529

530530
orderingCtor :: Text -> Expr
531-
orderingCtor = Constructor nullSourceSpan . orderingName
531+
orderingCtor = Constructor ss . orderingName
532532

533533
orderingBinder :: Text -> Binder
534-
orderingBinder name = ConstructorBinder nullSourceSpan (orderingName name) []
534+
orderingBinder name = ConstructorBinder ss (orderingName name) []
535535

536536
ordCompare :: Expr -> Expr -> Expr
537-
ordCompare = App . App (Var nullSourceSpan (Qualified (Just dataOrd) (Ident C.compare)))
537+
ordCompare = App . App (Var ss (Qualified (Just dataOrd) (Ident C.compare)))
538538

539539
ordCompare1 :: Expr -> Expr -> Expr
540-
ordCompare1 = App . App (Var (Qualified (Just dataOrd) (Ident C.compare1)))
540+
ordCompare1 = App . App (Var ss (Qualified (Just dataOrd) (Ident C.compare1)))
541541

542542
mkCtorClauses :: ((ProperName 'ConstructorName, [Type]), Bool) -> m [CaseAlternative]
543543
mkCtorClauses ((ctorName, tys), isLast) = do
544544
identsL <- replicateM (length tys) (freshIdent "l")
545545
identsR <- replicateM (length tys) (freshIdent "r")
546546
tys' <- mapM (replaceAllTypeSynonymsM syns) tys
547-
let tests = zipWith3 toOrdering (map (Var nullSourceSpan . Qualified Nothing) identsL) (map (Var nullSourceSpan . Qualified Nothing) identsR) tys'
548-
extras | not isLast = [ CaseAlternative [ ConstructorBinder nullSourceSpan (Qualified (Just mn) ctorName) (replicate (length tys) NullBinder)
547+
let tests = zipWith3 toOrdering (map (Var ss . Qualified Nothing) identsL) (map (Var ss . Qualified Nothing) identsR) tys'
548+
extras | not isLast = [ CaseAlternative [ ConstructorBinder ss (Qualified (Just mn) ctorName) (replicate (length tys) NullBinder)
549549
, NullBinder
550550
]
551551
(unguarded (orderingCtor "LT"))
552552
, CaseAlternative [ NullBinder
553-
, ConstructorBinder nullSourceSpan (Qualified (Just mn) ctorName) (replicate (length tys) NullBinder)
553+
, ConstructorBinder ss (Qualified (Just mn) ctorName) (replicate (length tys) NullBinder)
554554
]
555555
(unguarded (orderingCtor "GT"))
556556
]
@@ -562,7 +562,7 @@ deriveOrd ss mn syns ds tyConNm = do
562562
: extras
563563

564564
where
565-
caseBinder idents = ConstructorBinder nullSourceSpan (Qualified (Just mn) ctorName) (map (VarBinder nullSourceSpan) idents)
565+
caseBinder idents = ConstructorBinder ss (Qualified (Just mn) ctorName) (map (VarBinder ss) idents)
566566

567567
appendAll :: [Expr] -> Expr
568568
appendAll [] = orderingCtor "EQ"
@@ -590,7 +590,7 @@ deriveOrd1 ss =
590590
[ ValueDecl (ss, []) (Ident C.compare1) Public [] (unguarded dataOrdCompare)]
591591
where
592592
dataOrdCompare :: Expr
593-
dataOrdCompare = Var (Qualified (Just dataOrd) (Ident C.compare))
593+
dataOrdCompare = Var ss (Qualified (Just dataOrd) (Ident C.compare))
594594

595595
deriveNewtype
596596
:: forall m

tests/Language/PureScript/Ide/UsageSpec.hs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@ shouldBeUsage usage' (fp, range) =
3030
do
3131
fp `shouldBe` P.spanName usage'
3232

33-
(startLine, startColumn)
33+
(P.sourcePosLine (P.spanStart usage'), P.sourcePosColumn (P.spanStart usage'))
3434
`shouldBe`
35-
( P.sourcePosLine (P.spanStart usage')
36-
, P.sourcePosColumn (P.spanStart usage'))
37-
(endLine, endColumn)
35+
(startLine, startColumn)
36+
37+
(P.sourcePosLine (P.spanEnd usage'), P.sourcePosColumn (P.spanEnd usage'))
3838
`shouldBe`
39-
( P.sourcePosLine (P.spanEnd usage')
40-
, P.sourcePosColumn (P.spanEnd usage'))
39+
(endLine, endColumn)
4140

4241
spec :: Spec
4342
spec = describe "Finding Usages" $ do
@@ -58,7 +57,7 @@ spec = describe "Finding Usages" $ do
5857
Test.runIde [ load ["FindUsage", "FindUsage.Definition", "FindUsage.Reexport"]
5958
, usage (Test.mn "FindUsage.Definition") "$%" IdeNSValue
6059
]
61-
usage1 `shouldBeUsage` ("src" </> "FindUsage.purs", "9:3-9:9")
60+
usage1 `shouldBeUsage` ("src" </> "FindUsage.purs", "9:5-9:7")
6261
it "finds a reexported usage" $ do
6362
([_, Right (UsagesResult [usage1])], _) <- Test.inProject $
6463
Test.runIde [ load ["FindUsage", "FindUsage.Definition", "FindUsage.Reexport"]

0 commit comments

Comments
 (0)