Disallow top level cases with no arguments. Fixes #532
commit6814c94f21f2fc11a9b8c00e0239bf38b26a8b9e
authorNathan Faubion <nathan@n-son.com>
dateSat 16 Aug 2014, 15:36 (12 years ago)
parent5057aab
examples/failing/TopLevelCaseNoArgs.pursnew file+4
@@ -0,0 +1,4 @@
1+module Main where
2+ foo :: Number
3+ foo = 1
4+ foo = 2
src/Language/PureScript/Sugar/CaseDeclarations.hs+2
@@ -87,6 +87,8 @@ toDecls ds@(ValueDeclaration ident _ bs _ _ : _) = do
8787 let tuples = map toTuple ds
8888 unless (all ((== length bs) . length . fst) tuples) $
8989 throwError $ mkErrorStack ("Argument list lengths differ in declaration " ++ show ident) Nothing
90+ unless (not $ null bs) $
91+ throwError $ mkErrorStack ("Top level case disallowed in declaration " ++ show ident) Nothing
9092 caseDecl <- makeCaseDeclaration ident tuples
9193 return [caseDecl]
9294toDecls (PositionedDeclaration pos d : ds) = do