on master help sign in
Fixes layout parsing of operators
7932797Ahmad Salim Al-Sibahi
src/Idris/ParseOps.hs+6−1
@@ -55,7 +55,9 @@ toTable fs = map (map toBin)
55-- | Binary operator
55-- | Binary operator
56binary :: String -> (FC -> PTerm -> PTerm -> PTerm) -> Assoc -> Operator IdrisParser PTerm
56binary :: String -> (FC -> PTerm -> PTerm -> PTerm) -> Assoc -> Operator IdrisParser PTerm
57binary name f = Infix (do fc <- getFC
57binary name f = Infix (do fc <- getFC
58+ indentPropHolds gtProp
58 reservedOp name
59 reservedOp name
60+ indentPropHolds gtProp
59 doc <- option "" (docComment '^')
61 doc <- option "" (docComment '^')
60 return (f fc))
62 return (f fc))
61
63
@@ -63,12 +65,15 @@ binary name f = Infix (do fc <- getFC
63prefix :: String -> (FC -> PTerm -> PTerm) -> Operator IdrisParser PTerm
65prefix :: String -> (FC -> PTerm -> PTerm) -> Operator IdrisParser PTerm
64prefix name f = Prefix (do reservedOp name
66prefix name f = Prefix (do reservedOp name
65 fc <- getFC
67 fc <- getFC
68+ indentPropHolds gtProp
66 return (f fc))
69 return (f fc))
67
70
68-- | Backtick operator
71-- | Backtick operator
69backtick :: Operator IdrisParser PTerm
72backtick :: Operator IdrisParser PTerm
73+backtick = Infix (do indentPropHolds gtProp
70−backtick = Infix (do lchar '`'; n <- fnName
74+ lchar '`'; n <- fnName
71 lchar '`'
75 lchar '`'
76+ indentPropHolds gtProp
72 fc <- getFC
77 fc <- getFC
73 return (\x y -> PApp fc (PRef fc n) [pexp x, pexp y])) AssocNone
78 return (\x y -> PApp fc (PRef fc n) [pexp x, pexp y])) AssocNone
74
79
test/test036/expectednew file+1
@@ -0,0 +1 @@
1+Just 2
test/test036/runnew file+4
@@ -0,0 +1,4 @@
1+#!/usr/bin/env bash
2+idris $@ test036.idr -o test036
3+./test036
4+rm -f test036 *.ibc
test/test036/test036.idrnew file+17
@@ -0,0 +1,17 @@
1+module Main
2+
3+maybechoice : Maybe a -> Maybe a -> Maybe a
4+maybechoice (Just x) _ = Just x
5+maybechoice Nothing r = r
6+
7+unused : a -> a -> a
8+unused _ s = s
9+
10+doTest : Maybe Nat
11+doTest = do
12+ a <- Nothing
13+ unused a (return 3)
14+ `maybechoice` return 2
15+
16+main : IO ()
17+main = putStrLn . show $ doTest