GHC issues
https://gitlab.haskell.org/ghc/ghc/-/issues
2019-07-07T18:35:37Z
https://gitlab.haskell.org/ghc/ghc/-/issues/10508
comipleExpr or :def in GHCi rejects valid multiline expr or accepts invalid expr
2019-07-07T18:35:37Z
Zejun Wu
comipleExpr or :def in GHCi rejects valid multiline expr or accepts invalid expr
dynComipleExpr will accept invalid expr or reject valid expr because it compiles the expr as `"let _dynComipleExpr = (" ++ expr ++ ")"`.
```hs
-- tail -n 15 Test.hs
forM_ exprs $ \expr ->
handleSourceError printException $ do
...
dynComipleExpr will accept invalid expr or reject valid expr because it compiles the expr as `"let _dynComipleExpr = (" ++ expr ++ ")"`.
```hs
-- tail -n 15 Test.hs
forM_ exprs $ \expr ->
handleSourceError printException $ do
dyn <- dynCompileExpr expr
liftIO $ print dyn
where
exprs =
[ ""
, "(),()"
, "()"
, "\"test\""
, unlines [ "[()]"
, " :: [()]"
]
]
-- ./Test /lib/ghc
<<()>>
<<((),())>>
<<()>>
<<[Char]>>
<interactive>:2:2:
parse error (possibly incorrect indentation or mismatched brackets)
```
As `:def` and `:cmd` uses `compileExpr`, they have the same problem:
```
GHCi, version 7.10.1: http://www.haskell.org/ghc/ :? for help
Prelude> :{
Prelude| :cmd return $ unlines
Prelude| [ "1"
Prelude| , "2"
Prelude| ]
Prelude| :}
<interactive>:2:3:
parse error (possibly incorrect indentation or mismatched brackets)
Prelude> import Prelude (return, id, ShowS, IO)
Prelude> :cmd return "0"
<interactive>:1:42:
Not in scope: type constructor or class ‘String’
Prelude> type String = ShowS
Prelude> :cmd return id
zsh: segmentation fault (core dumped) ghci
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 7.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | GHC API |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | simonmar |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"comipleExpr or :def in GHCi rejects valid multiline expr or accepts invalid expr","status":"New","operating_system":"","component":"GHC API","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"watashi"},"version":"7.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["simonmar"],"type":"Bug","description":"dynComipleExpr will accept invalid expr or reject valid expr because it compiles the expr as `\"let _dynComipleExpr = (\" ++ expr ++ \")\"`.\r\n\r\n{{{#!hs\r\n-- tail -n 15 Test.hs\r\n forM_ exprs $ \\expr ->\r\n handleSourceError printException $ do\r\n dyn <- dynCompileExpr expr\r\n liftIO $ print dyn\r\n where\r\n exprs =\r\n [ \"\"\r\n , \"(),()\"\r\n , \"()\"\r\n , \"\\\"test\\\"\"\r\n , unlines [ \"[()]\"\r\n , \" :: [()]\"\r\n ]\r\n ]\r\n-- ./Test /lib/ghc\r\n<<()>>\r\n<<((),())>>\r\n<<()>>\r\n<<[Char]>>\r\n\r\n<interactive>:2:2:\r\n parse error (possibly incorrect indentation or mismatched brackets)\r\n}}}\r\n\r\nAs `:def` and `:cmd` uses `compileExpr`, they have the same problem:\r\n{{{\r\nGHCi, version 7.10.1: http://www.haskell.org/ghc/ :? for help\r\nPrelude> :{\r\nPrelude| :cmd return $ unlines\r\nPrelude| [ \"1\"\r\nPrelude| , \"2\"\r\nPrelude| ]\r\nPrelude| :}\r\n\r\n<interactive>:2:3:\r\n parse error (possibly incorrect indentation or mismatched brackets)\r\nPrelude> import Prelude (return, id, ShowS, IO)\r\nPrelude> :cmd return \"0\"\r\n\r\n<interactive>:1:42:\r\n Not in scope: type constructor or class ‘String’\r\nPrelude> type String = ShowS\r\nPrelude> :cmd return id\r\nzsh: segmentation fault (core dumped) ghci\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->
8.0.1
Zejun Wu
Zejun Wu
https://gitlab.haskell.org/ghc/ghc/-/issues/10439
Opt_ImplicitImportQualified doesn't work for constructor field name
2019-07-07T18:35:54Z
Zejun Wu
Opt_ImplicitImportQualified doesn't work for constructor field name
```hs
-- ghci -fimplicit-import-qualified
Prelude> let tree = Data.Tree.Node 0 []
Prelude> Data.Tree.rootLabel tree
0
Prelude> let f i j = i { Data.Tree.rootLabel = j }
<interactive>:4:17:
‘Data.Tree.rootLabel’ is not a (visible) co...
```hs
-- ghci -fimplicit-import-qualified
Prelude> let tree = Data.Tree.Node 0 []
Prelude> Data.Tree.rootLabel tree
0
Prelude> let f i j = i { Data.Tree.rootLabel = j }
<interactive>:4:17:
‘Data.Tree.rootLabel’ is not a (visible) constructor field name
Prelude> import qualified Data.Tree
Prelude Data.Tree> let f i j = i { Data.Tree.rootLabel = j }
Prelude Data.Tree> f tree 1
Node {rootLabel = 1, subForest = []}
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 7.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | GHCi |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | hvr |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Opt_ImplicitImportQualified doesn't work for constructor field name","status":"New","operating_system":"","component":"GHCi","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"watashi"},"version":"7.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["hvr"],"type":"Bug","description":"{{{#!hs\r\n-- ghci -fimplicit-import-qualified\r\nPrelude> let tree = Data.Tree.Node 0 []\r\nPrelude> Data.Tree.rootLabel tree\r\n0\r\nPrelude> let f i j = i { Data.Tree.rootLabel = j }\r\n\r\n<interactive>:4:17:\r\n ‘Data.Tree.rootLabel’ is not a (visible) constructor field name\r\nPrelude> import qualified Data.Tree\r\nPrelude Data.Tree> let f i j = i { Data.Tree.rootLabel = j }\r\nPrelude Data.Tree> f tree 1\r\nNode {rootLabel = 1, subForest = []}\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->
8.0.1
Zejun Wu
Zejun Wu