on master help sign in
Only allow @ patterns on LHS

It's meaningless on the RHS and clashes with explicit instances, so should be disallowed in the parser.

commitf733bf0e3056ed8a893c7e04cdfbcaad64f3b7a8 authorEdwin Brady <ecb10@st-andrews.ac.uk> dateSun 21 Dec 2014, 01:06 (12 years ago) parentca4b563
2 files changed+6−20
src/Idris/ParseExpr.hs+6−4 test/reg050/expected−16
src/Idris/ParseExpr.hs+6−4
@@ -332,10 +332,12 @@ simpleExpr syn =
332332 [pexp (PConstant (Str (show str)))])
333333 <|> do fc <- getFC
334334 x <- fnName
335− option (PRef fc x)
336− (do reservedOp "@"
337− s <- simpleExpr syn
338− return (PAs fc x s))
335+ if inPattern syn
336+ then option (PRef fc x)
337+ (do reservedOp "@"
338+ s <- simpleExpr syn
339+ return (PAs fc x s))
340+ else return (PRef fc x)
339341 <|> idiom syn
340342 <|> listExpr syn
341343 <|> alt syn
test/reg050/expected−16
@@ -10,19 +10,3 @@ When elaborating an application of function Prelude.Monad.>>=:
1010 List
1111 with
1212 \{uv0} => argTy -> uv
13−./baddoublebang.idr:6:26: error: not
14− a terminator, expected: "$",
15− "$>", "&&", "*", "+", "++", "-",
16− "->", ".", "/", "/=", "::", ";",
17− "<", "<#>", "<$", "<$>", "<*>",
18− "<+>", "<->", "<<", "<=", "<|>",
19− "=", "==", ">", ">=", ">>",
20− ">>=", "@", "\\\\", "`", "in",
21− "||", "~=~",
22− ambiguous use of a left-associative operator,
23− ambiguous use of a non-associative operator,
24− ambiguous use of a right-associative operator,
25− end of input, function argument,
26− matching application expression
27−doubleBang mmn = do pure !!mmn
28− ^