From 63956311f1771e87e24deb18c0a52dda50e58075 Mon Sep 17 00:00:00 2001 From: Fredrik Wallberg Date: Sat, 1 Jul 2017 23:16:32 +0200 Subject: [PATCH 1/2] Require single-method instance declarations to be indented Resolves https://github.com/purescript/purescript/issues/2947 --- examples/failing/2947.purs | 10 ++++++++++ examples/passing/2947.purs | 11 +++++++++++ src/Language/PureScript/Parser/Declarations.hs | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 examples/failing/2947.purs create mode 100644 examples/passing/2947.purs diff --git a/examples/failing/2947.purs b/examples/failing/2947.purs new file mode 100644 index 0000000000..c0f191b5bd --- /dev/null +++ b/examples/failing/2947.purs @@ -0,0 +1,10 @@ +-- @shouldFailWith ErrorParsingModule + +module Main where + +import Prelude + +data Foo = Foo + +instance eqFoo :: Eq Foo where +eq _ _ = true diff --git a/examples/passing/2947.purs b/examples/passing/2947.purs new file mode 100644 index 0000000000..fbc1b201fb --- /dev/null +++ b/examples/passing/2947.purs @@ -0,0 +1,11 @@ +module Main where + +import Prelude +import Control.Monad.Eff.Console (log) + +data Foo = Foo + +instance eqFoo :: Eq Foo where + eq _ _ = true + +main = log "Done" diff --git a/src/Language/PureScript/Parser/Declarations.hs b/src/Language/PureScript/Parser/Declarations.hs index 1dbb9d5d4c..420c1557e6 100644 --- a/src/Language/PureScript/Parser/Declarations.hs +++ b/src/Language/PureScript/Parser/Declarations.hs @@ -227,7 +227,7 @@ parseTypeInstanceDeclaration = do instanceDecl <- parseInstanceDeclaration members <- P.option [] $ do indented *> reserved "where" - mark (P.many (same *> declsInInstance)) + indented *> mark (P.many (same *> declsInInstance)) return $ instanceDecl (ExplicitInstance members) where declsInInstance :: TokenParser Declaration From 24427f09ec099f304d2e142d2e6e6a728baf7b79 Mon Sep 17 00:00:00 2001 From: Fredrik Wallberg Date: Tue, 4 Jul 2017 21:48:56 +0200 Subject: [PATCH 2/2] Add name and licensing notice --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index e653c77107..2829d4664c 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -82,6 +82,7 @@ If you would prefer to use different terms, please use the section below instead | [@phiggins](https://github.com/phiggins) | Pete Higgins | [MIT license](http://opensource.org/licenses/MIT) | | [@philopon](https://github.com/philopon) | Hirotomo Moriwaki | [MIT license](http://opensource.org/licenses/MIT) | | [@pseudonom](https://github.com/pseudonom) | Eric Easley | [MIT license](http://opensource.org/licenses/MIT) | +| [@quesebifurcan](https://github.com/quesebifurcan) | Fredrik Wallberg | [MIT license](http://opensource.org/licenses/MIT) | | [@rightfold](https://github.com/rightfold) | rightfold | [MIT license](https://opensource.org/licenses/MIT) | | [@robdaemon](https://github.com/robdaemon) | Robert Roland | [MIT license](http://opensource.org/licenses/MIT) | | [@RossMeikleham](https://github.com/RossMeikleham) | Ross Meikleham | [MIT license](http://opensource.org/licenses/MIT) |