git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix issue with empty binders in top-level declarations
commit3c9878dcd84be0e7263129e0dbc30addd90b47d3 authorPhil Freeman <paf31@cantab.net> dateSun 21 Sep 2014, 21:39 (12 years ago) parentbe36346
1 file changed+3−2
src/Language/PureScript/Sugar/CaseDeclarations.hs+3−2
src/Language/PureScript/Sugar/CaseDeclarations.hs+3−2
@@ -19,6 +19,7 @@ module Language.PureScript.Sugar.CaseDeclarations (
1919 desugarCasesModule
2020) where
2121
22+import Data.Maybe (isJust)
2223import Data.Monoid ((<>))
2324import Data.List (nub, groupBy)
2425
@@ -85,11 +86,11 @@ toDecls [ValueDeclaration ident nameKind bs Nothing val] | all isVarBinder bs =
8586 body = foldr (Abs . Left) val args
8687 guardWith (strMsg "Overlapping function argument names") $ length (nub args) == length args
8788 return [ValueDeclaration ident nameKind [] Nothing body]
88−toDecls ds@(ValueDeclaration ident _ bs _ _ : _) = do
89+toDecls ds@(ValueDeclaration ident _ bs g _ : _) = do
8990 let tuples = map toTuple ds
9091 unless (all ((== length bs) . length . fst) tuples) $
9192 throwError $ mkErrorStack ("Argument list lengths differ in declaration " ++ show ident) Nothing
92− unless (not $ null bs) $
93+ unless (not (null bs) || isJust g) $
9394 throwError $ mkErrorStack ("Top level case disallowed in declaration " ++ show ident) Nothing
9495 caseDecl <- makeCaseDeclaration ident tuples
9596 return [caseDecl]