summaryrefslogtreecommitdiff
path: root/compiler/hsSyn/HsUtils.lhs
diff options
context:
space:
mode:
authorSimon Marlow <simonmar@microsoft.com>2006-10-10 15:30:23 +0000
committerSimon Marlow <simonmar@microsoft.com>2006-10-10 15:30:23 +0000
commit85eebc52605f5fd4d3bbdb1a37f7134948f740ca (patch)
treec0089cd5128a5a53019b397a5c2a6791eb9b48f9 /compiler/hsSyn/HsUtils.lhs
parent30098da67fd3ce50ef5a110f57c1780002f83615 (diff)
downloadhaskell-85eebc52605f5fd4d3bbdb1a37f7134948f740ca.tar.gz
getMainDeclBinder should return Nothing for a binding with no variables
See test rn003
Diffstat (limited to 'compiler/hsSyn/HsUtils.lhs')
-rw-r--r--compiler/hsSyn/HsUtils.lhs5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/hsSyn/HsUtils.lhs b/compiler/hsSyn/HsUtils.lhs
index 5d7132ec74..b0978ec649 100644
--- a/compiler/hsSyn/HsUtils.lhs
+++ b/compiler/hsSyn/HsUtils.lhs
@@ -428,7 +428,10 @@ collect_pat other acc = acc -- Literals, vars, wildcard
getMainDeclBinder :: HsDecl name -> Maybe name
getMainDeclBinder (TyClD d) = Just (tcdName d)
-getMainDeclBinder (ValD d) = Just ((unLoc . head) (collectAcc d []))
+getMainDeclBinder (ValD d)
+ = case collectAcc d [] of
+ [] -> Nothing -- see rn003
+ (name:_) -> Just (unLoc name)
getMainDeclBinder (SigD d) = sigNameNoLoc d
getMainDeclBinder (ForD (ForeignImport name _ _)) = Just (unLoc name)
getMainDeclBinder (ForD (ForeignExport name _ _)) = Just (unLoc name)