[GHC] #16346: Lint error on master: Occurrence is GlobalId, but binding is LocalId

#16346: Lint error on master: Occurrence is GlobalId, but binding is LocalId -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I'm getting this Lint error when validating 'master', when compiling `PrelNames.hs` with the stage1 compiler. {{{ *** Core Lint errors : in result of Simplifier *** <no location info>: warning: In the expression: Name (External modu_a3Ct) (OccName dt_X6Ya dt_X6Yc) dt2_a6Yf noSrcSpan Occurrence is GlobalId, but binding is LocalId noSrcSpan :: SrcSpan [GblId, Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False, WorkFree=True, Expandable=False, Guidance=IF_ARGS [] 10 0}] }}} How come this got past CI? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16346 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16346: Lint error on master: Occurrence is GlobalId, but binding is LocalId -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by monoidal): Does the test program from #16288 work on your ghc-stage1? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16346#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16346: Lint error on master: Occurrence is GlobalId, but binding is LocalId -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Yes I think so. But the real issue is this in `SimplEnv.refineFromInScope`: {{{ refineFromInScope :: InScopeSet -> Var -> Var refineFromInScope in_scope v | isLocalId v = case lookupInScope in_scope v of Just v' -> v' Nothing -> WARN( True, ppr v ) v -- This is an error! | otherwise = v }}} Notice that we don't look `GlobalId`s up in the in-scope set. Yet that is the mechanism that ensures that in a situation like {{{ let f_2dr[LclId] = blah in ...M.f_2df[GblId]... }}} (which has a local binding for a `GlobalId`), we transform to {{{ let f_2dr[LclId] = blah in ...f_2df[LclId]... }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16346#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16346: Lint error on master: Occurrence is GlobalId, but binding is LocalId -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Changing the definition of `refineFromInScope` to {{{ | isLocalId v = case lookupInScope in_scope v of Just v' -> v' Nothing -> WARN( True, ppr v ) v -- This is an error! | otherwise = case lookupInScope in_scope v of Just v' -> v' Nothing -> v }}} fixes the panic. (Although in a very unsatisfactory way, because we thereby look up ''every'' `GlobalId`.) But we just get another panic! This time in the `cabal` library, module `Distribution.Types.ComponentRequestedSpec`: {{{ *** Core Lint errors : in result of Simplifier *** <no location info>: warning: [in body of lambda with binder w5_afxc :: Success ...snipped... Out of scope: $fSumSizeM2_r14m :: Word64 [LclId] }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16346#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16346: Lint error on master: Occurrence is GlobalId, but binding is LocalId -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Here's why the second crash happens. We start with {{{ case M.f_2dr[GblId] of f' { W# y -> let f_2dr[LclId] = f' in case M.f_2dr[GblId] of { W# z -> blah }}} (All this is in the body of `$s$fGBinaryGetTYPE:+:1_sfOT` in `Distribution.Types.ComponentRequestedSpec`.) Then * It turns out that `M.f_2dr` is a HNF so the first case can vanish. We extend the substitution with `f' :-> M.f_2dr[GblId]`. * We simplify the RHS of the `let` to get `M.f_2dr[GblId]` * We simplify the let-binder. It's not in scope, so we don't mess with its unique, and we extend the in-scope set with `M.f_2dr[LclId]`. * Now post-inline-unconditionally fires, so we extend the substitution with `f_2dr :-> M.f_2dr[GblId]` * Now at the occurrence of `M.f_2dr[GblId]` we find it in the substitution, mapping to, well, `M.f_2dr[GblId]`. * Then we look that up in the in-scope set, and get `M.f_2dr[LclId]` * And that is not in scope. What a mess. My conclusion: it's a total disaster to have a local binding for a `LocalId` that shares a unique with a `GlobalId`. We have multiple hacks to avoid trouble, and they don't even work. Let's stop doing it. See #16296. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16346#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16346: Lint error on master: Occurrence is GlobalId, but binding is LocalId -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Since this kills validate, I have a quick-fix in flight. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16346#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16346: Lint error on master: Occurrence is GlobalId, but binding is LocalId -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #16296 | Differential Rev(s): Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/416 -------------------------------------+------------------------------------- Changes (by RyanGlScott): * differential: => https://gitlab.haskell.org/ghc/ghc/merge_requests/416 * related: => #16296 Comment: simonpj, what is the status of this ticket post-[https://gitlab.haskell.org/ghc/ghc/commit/0eb7cf03da3783ca887d5de44d312cf6f3... 0eb7cf03da3783ca887d5de44d312cf6f3a4113c]? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16346#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16346: Lint error on master: Occurrence is GlobalId, but binding is LocalId -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #16296 | Differential Rev(s): Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/416 -------------------------------------+------------------------------------- Comment (by simonpj): This ticket is fixed by the patch in comment:6. This is a quick-fix, not the proper solution. But we have #16296 for the proper solution, so I'll close this. We don't need a test case because all CI runs would (now, I hope) fail if this patch wasn't working. Matthew made some other change that makes CI catch these failures, whereas previously they were sneaking through. Matthew, perhaps you can just add a link to the CI-fix, and then close this? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16346#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16346: Lint error on master: Occurrence is GlobalId, but binding is LocalId
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner: (none)
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Compiler | Version: 8.6.3
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #16296 | Differential Rev(s):
Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/416
-------------------------------------+-------------------------------------
Changes (by monoidal):
* status: new => closed
* resolution: => fixed
Comment:
CI was fixed in
{{{
commit 44ad7215a11cb49651233646c30ced9eb72eaad2
Author: Matthew Pickering

#16346: Lint error on master: Occurrence is GlobalId, but binding is LocalId -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.10.1 Component: Compiler | Version: 8.6.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #16296 | Differential Rev(s): Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/416 -------------------------------------+------------------------------------- Changes (by RyanGlScott): * milestone: => 8.10.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16346#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16346: Lint error on master: Occurrence is GlobalId, but binding is LocalId
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner: (none)
Type: bug | Status: closed
Priority: normal | Milestone: 8.10.1
Component: Compiler | Version: 8.6.3
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #16296 | Differential Rev(s):
Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/416
-------------------------------------+-------------------------------------
Comment (by Matthew Pickering
participants (1)
-
GHC