
#15617: Unboxed tuples/sum error message on `a = show 5` in expression evaluation and interactive modes -------------------------------------+------------------------------------- Reporter: ChaiTRex | Owner: | JulianLeviston Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.6.1-beta1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by JulianLeviston): To refresh my brain (and so I don't have to re-load this into my brain over and over)... as per above, but with annotation: 1. In `ghc/Main.hs`, the `main` function is the entry point for all of GHC. 1. The line with `(mode, argv3, flagWarnings) <- parseModeFlags argv2` parses the mode flags out. There are two possible cases here: either we have a `Left preStartupMode` or `Right postStartupMode`. The `preStartupMode` case is only for doing things before GHC starts up; things such as outputting the version number, etc (ie not executing code). So, we're only interested in the `Right postStartupMode` variant. 1. Continuing on, we start `GHC` by using `GHC.runGhc` with `mbMinusB`, then pull the flags out with `GHC.getSessionDynFlags`. We then `case` on `postStartupMode` which itself is an `Either` as well... it's similar to above, but here we have some `preLoadMode` values that (I'm assuming) can only be got when `GHC` has started up. Things like showing info, ghc usage, ghci usage and printing the flags. Here, though, we're only interested in the `Right` variant again — the `postLoadMode` value gets pattern matched out and; 1. next this hits the `main'` function as: `main' postLoadMode dflags argv3 flagWarnings`. This function then cases on `postLoadMode`... and the only branches of this we're really interested in is `DoInteractive -> (CompManager, HscInterpreted, LinkInMemory)` and `DoEval _ -> (CompManager, HscInterpreted, LinkInMemory)`... there are five other matches, but they're make, backpack, something called MkDependHS and also AbiHash, then the catchall (ie `_`). Essentially we want to block optimisation on the interactive and eval cases. So, this matches `(mode, lang, link)` to the values `(CompManager, HscInterpreted, linkInMemory)` respectively for both of these cases (interactive and eval). 1. Next we use a series of `let` expressions building up dflags1, dflags2, dflags3, etc. then, at the very end, we have another case stateament inside of an evaluation of `handleSourceError` to handle source code errors... again, the only two cases we care about are `DoInteractive` and `DoEval exprs`, both of which evalute to `ghciUI` expressions. Respectively: `ghciUI hsc_env dflags6 srcs Nothing` and `ghciUI hsc_env dflags6 srcs $ Just $ reverse exprs`. 1. The `ghciUI` function pulls the flags out after initializing the plugins with the `hsc_env` and `dflags0`, then sets this into the session with `GHC.setSessionDynFlags`. We then call the `interactiveUI` function with args thusly: `interactiveUI defaultGhciSettings srcs maybe_expr`. This function comes from the `GHCi.UI` module in `ghc/GHCi/UI.hs`. So, we want to investigate `interactiveUI` in `ghc/GHCi/UI.hs`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15617#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler