-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace undefined with more descriptive error
- Loading branch information
1 parent
fbbf632
commit a71aa7f
Showing
3 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
-- https://github.com/haskell/alex/pull/262 | ||
-- https://gitlab.haskell.org/ghc/ghc/-/issues/25609 | ||
-- | ||
-- Error happens when using alexScan with a lexer that | ||
-- inspects the context. | ||
|
||
import Control.Exception | ||
import Data.List (isInfixOf) | ||
} | ||
|
||
%wrapper "basic" | ||
|
||
:- | ||
.* / { \state _ _ _ -> state == 'x' } { id } | ||
|
||
{ | ||
main :: IO () | ||
main = do | ||
result <- try $ evaluate $ alexScan ('\n', [], "") 0 `seq` () | ||
case result of | ||
Left (e :: SomeException) | ||
| "use alexScanUser instead" `isInfixOf` show e | ||
-> pure () | ||
_ -> error $ "Got unexpected result: " ++ show result | ||
} |