git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Disallow top level cases with no arguments. Fixes #532
6814c94Nathan Faubion
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
87 let tuples = map toTuple ds
87 let tuples = map toTuple ds
88 unless (all ((== length bs) . length . fst) tuples) $
88 unless (all ((== length bs) . length . fst) tuples) $
89 throwError $ mkErrorStack ("Argument list lengths differ in declaration " ++ show ident) Nothing
89 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
90 caseDecl <- makeCaseDeclaration ident tuples
92 caseDecl <- makeCaseDeclaration ident tuples
91 return [caseDecl]
93 return [caseDecl]
92toDecls (PositionedDeclaration pos d : ds) = do
94toDecls (PositionedDeclaration pos d : ds) = do