Commit e2b579e8 authored by thomie's avatar thomie Committed by Austin Seipp

Parser: revert some error messages to what they were before 7.10

Among doing other things, Phab:D201 (bc2289e1)
tried to improve the error messages thrown by the parser. For example a missing
else clause now prints "parse error in if statement: else clause empty" instead
of "parse error (possibly incorrect indentation or mismatched brackets)".

Some error messages got much worse however (see tests), and the result seems to
be a net negative. Although not entirely satisfactory, this commits therefore
reverts those parser changes.

Reviewed By: austin

Differential Revision: https://phabricator.haskell.org/D1309

GHC Trac Issues: #10498
parent 69a6e425
......@@ -2182,37 +2182,6 @@ exp10 :: { LHsExpr RdrName }
-- hdaume: core annotation
| fexp { $1 }
-- parsing error messages go below here
| '\\' apat apats opt_asig '->' error {% parseErrorSDoc (combineLocs $1 $5) $ text
"parse error in lambda: no expression after '->'"
}
| '\\' error {% parseErrorSDoc (getLoc $1) $ text
"parse error: naked lambda expression '\'"
}
| 'let' binds 'in' error {% parseErrorSDoc (combineLocs $1 $2) $ text
"parse error in let binding: missing expression after 'in'"
}
| 'let' binds error {% parseErrorSDoc (combineLocs $1 $2) $ text
"parse error in let binding: missing required 'in'"
}
| 'let' error {% parseErrorSDoc (getLoc $1) $ text
"parse error: naked let binding"
}
| 'if' exp optSemi 'then' exp optSemi
'else' error {% hintIf (combineLocs $1 $5) "else clause empty" }
| 'if' exp optSemi 'then' exp optSemi error {% hintIf (combineLocs $1 $5) "missing required else clause" }
| 'if' exp optSemi 'then' error {% hintIf (combineLocs $1 $2) "then clause empty" }
| 'if' exp optSemi error {% hintIf (combineLocs $1 $2) "missing required then and else clauses" }
| 'if' error {% hintIf (getLoc $1) "naked if statement" }
| 'case' exp 'of' error {% parseErrorSDoc (combineLocs $1 $2) $ text
"parse error in case statement: missing list after '->'"
}
| 'case' exp error {% parseErrorSDoc (combineLocs $1 $2) $ text
"parse error in case statement: missing required 'of'"
}
| 'case' error {% parseErrorSDoc (getLoc $1) $ text
"parse error: naked case statement"
}
optSemi :: { ([Located a],Bool) }
: ';' { ([$1],True) }
| {- empty -} { ([],False) }
......
ParserNoLambdaCase.hs:3:5: parse error: naked lambda expression ''
ParserNoLambdaCase.hs:3:6: error: parse error on input ‘case’
{-# LANGUAGE LambdaCase #-}
module T10498a where
-- ghc-7.10 would show the unhelpful error message:
--
-- T10498a.hs:10:5:
-- parse error in if statement: missing required else clause
foo =
if True
then
\case ->
1 -> 2
else id
T10498a.hs:12:15: error: parse error on input ‘->’
module T10498b where
-- ghc-7.10 would show the unhelpful error message:
--
-- T10498b.hs:7:5: parse error in if statement: naked if statement
f = if module then True else False
T10498b.hs:7:8: error: parse error on input ‘module’
......@@ -91,3 +91,5 @@ test('T9225', normal, compile_fail, [''])
test('T10196Fail1', normal, compile_fail, [''])
test('T10196Fail2', normal, compile_fail, [''])
test('T10196Fail3', expect_broken(10196), compile_fail, [''])
test('T10498a', normal, compile_fail, [''])
test('T10498b', normal, compile_fail, [''])
readFail020.hs:3:5:
parse error in let binding: missing required 'in'
readFail020.hs:3:16: error: parse error on input ‘}’
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment