Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,876
    • Issues 4,876
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 458
    • Merge requests 458
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #21440
Closed
Open
Created Apr 27, 2022 by Andreas Klebinger@AndreasKDeveloper

exprIsDeadEnd is broken

exprIsDeadEnd :: CoreExpr -> Bool
-- See Note [Bottoming expressions]
exprIsDeadEnd e
  | isEmptyTy (exprType e)
  = True
  | otherwise
  = go 0 e
  where
    go n (Var v)                 = isDeadEndId v &&  n >= idArity v
    go n (App e a) | isTypeArg a = go n e
                   | otherwise   = go (n+1) e

We have

failIO :: forall a. String -> IO a
[Arity = 0 -- unknown arity
, ...]
failIO = failIO1

We call

exprIsDead (App failIO msg)
=> AppCase
go 1 failIO 
=> Var case
isDeadEndId failIO &&  1 >= idArity failIO
=>
True &&  n >= 1 >= 0
=>
True

The problem is that we trust idArity to return a known arity. But it can also return zero if the arity is unknown.

That means for a potentially bottoming function we always get True for exprIsDeadEnd if it has unknown Arity.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking