Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
haskell-wasm
GHC
Commits
500d8cb8
Commit
500d8cb8
authored
1 year ago
by
Jade
Committed by
Marge Bot
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
prevent GHCi (and runghc) from suggesting other symbols when not finding main
Fixes: #23996
parent
5a932cf2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ghc/GHCi/UI.hs
+18
-7
18 additions, 7 deletions
ghc/GHCi/UI.hs
testsuite/tests/ghc-e/should_fail/T18441fail18.stderr
+2
-3
2 additions, 3 deletions
testsuite/tests/ghc-e/should_fail/T18441fail18.stderr
with
20 additions
and
10 deletions
ghc/GHCi/UI.hs
+
18
−
7
View file @
500d8cb8
...
...
@@ -1622,13 +1622,24 @@ pprInfo (thing, fixity, cls_insts, fam_insts, docs)
runMain
::
GhciMonad
m
=>
String
->
m
()
runMain
s
=
case
toArgsNoLoc
s
of
Left
err
->
liftIO
(
hPutStrLn
stderr
err
)
Right
args
->
do
dflags
<-
getDynFlags
let
main
=
fromMaybe
"main"
(
mainFunIs
dflags
)
-- Wrap the main function in 'void' to discard its value instead
-- of printing it (#9086). See Haskell 2010 report Chapter 5.
doWithArgs
args
$
"Control.Monad.void ("
++
main
++
")"
Left
err
->
liftIO
(
hPutStrLn
stderr
err
)
Right
args
->
doWithMain
(
doWithArgs
args
)
where
doWithMain
fun
=
do
dflags
<-
getDynFlags
let
main
=
fromMaybe
"main"
(
mainFunIs
dflags
)
handleSourceError
printErrAndMaybeExit
$
do
-- doing this will prevent the main to run when it is not in scope
-- this might seem useless, but it doesn't suggest other functions
-- to be used, which is exactly what we want here. See #23996.
_
<-
GHC
.
parseName
main
-- Wrap the main function in 'void' to discard its value instead
-- of printing it (#9086). See Haskell 2010 report Chapter 5.
fun
$
"Control.Monad.void ("
++
main
++
")"
-----------------------------------------------------------------------------
-- :run
...
...
This diff is collapsed.
Click to expand it.
testsuite/tests/ghc-e/should_fail/T18441fail18.stderr
+
2
−
3
View file @
500d8cb8
<interactive>:0:53: error: [GHC-88464]
Variable not in scope: main :: IO a0
Suggested fix: Perhaps use ‘min’ (imported from Prelude)
<interactive>:1:1: error: [GHC-76037]
Not in scope: ‘main’
1
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment