Merge pull request #566 from natefaubion/issue-532
Disallow top level cases with no arguments. Fixes #532
commit0239693d3264a284215dcec49ed6f76ef85cabdd
authorPhil Freeman <paf31@cantab.net>
dateSat 16 Aug 2014, 14:00 (12 years ago)
parent5057aab6814c94
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