diff options
| author | Ben Gamari <bgamari.foss@gmail.com> | 2015-06-16 20:01:22 +0200 |
|---|---|---|
| committer | Ben Gamari <ben@smart-cactus.org> | 2015-06-16 20:01:22 +0200 |
| commit | 1ff7f09b3abedb2a6daf384b55ad3d0134f0d174 (patch) | |
| tree | 34ad913bdc6f19ab1151d90cfa14e4aedf9ffe58 /compiler/parser | |
| parent | b0d8ba368f031279444c851dbca499d7e272f74c (diff) | |
| download | haskell-1ff7f09b3abedb2a6daf384b55ad3d0134f0d174.tar.gz | |
Lexer: Suggest adding 'let' on unexpected '=' token
Summary:
I've heard numerous fledgling Haskeller's complain about the behavior of
ghci regarding bindings. While most REPLs accept bindings of the form
`x = 42`, GHCi is implicitly a `do` block, meaning that the user must
know to use a `let` to introduce a binding.
Here we suggest to the user that they may need a `let` and give them a
small example in the event that we find an unexpected `=` token.
Reviewers: austin
Reviewed By: austin
Subscribers: thomie, bgamari
Differential Revision: https://phabricator.haskell.org/D980
Diffstat (limited to 'compiler/parser')
| -rw-r--r-- | compiler/parser/Lexer.x | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x index 1be724526f..5839a410fb 100644 --- a/compiler/parser/Lexer.x +++ b/compiler/parser/Lexer.x @@ -2229,6 +2229,9 @@ srcParseErr dflags buf len (text "Perhaps you intended to use TemplateHaskell") $$ ppWhen (token == "<-") (text "Perhaps this statement should be within a 'do' block?") + $$ ppWhen (token == "=") + (text "Perhaps you need a 'let' in a 'do' block?" + $$ text "e.g. 'let x = 5' instead of 'x = 5'") where token = lexemeToString (offsetBytes (-len) buf) len th_enabled = xopt Opt_TemplateHaskell dflags |
