From: lewie Date: Mon, 23 Apr 2001 19:34:57 +0000 (+0000) Subject: [project @ 2001-04-23 19:34:57 by lewie] X-Git-Tag: Approximately_9120_patches~2117 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=b5f00004d9ac04dee3d36a72374e9712fbc87a13;p=ghc-hetmet.git [project @ 2001-04-23 19:34:57 by lewie] Fix for infix decl w/ infix data constructor. GHC was rejecting this: infix 2 |- ps |- q:qs = undefined It parses the def as ((ps |- q) : qs), and doesn't have the fixity info around at the point where it decides what is being defined. Lacking anything else to go on, it decides that `:' is being defined. Fortunately, we don't really need fixity info to parse this correctly, as a data constructor is always the wrong choice ;-) The fix is to dive into the left-hand-side until we find a non-data constructor. This is naive - consider the case where `|-' has a high precedence. Fortunately, someone clever put in a static check later on, presumably at the point where we have all the fixity info, that rejects the definition as bogus. Yeah! --- diff --git a/ghc/compiler/parser/ParseUtil.lhs b/ghc/compiler/parser/ParseUtil.lhs index 969ca93..e444450 100644 --- a/ghc/compiler/parser/ParseUtil.lhs +++ b/ghc/compiler/parser/ParseUtil.lhs @@ -271,6 +271,11 @@ checkValSig other ty loc = parseError "Type signature given for an expressio isFunLhs :: RdrNameHsExpr -> [RdrNameHsExpr] -> Maybe (RdrName, Bool, [RdrNameHsExpr]) isFunLhs (OpApp l (HsVar op) fix r) es | not (isRdrDataCon op) = Just (op, True, (l:r:es)) + | otherwise + = case isFunLhs l es of + Just (op', True, j : k : es') -> + Just (op', True, j : OpApp k (HsVar op) fix r : es') + Nothing -> Nothing isFunLhs (HsVar f) es | not (isRdrDataCon f) = Just (f,False,es) isFunLhs (HsApp f e) es = isFunLhs f (e:es)