Model divergence of retry# as ThrowsExn, not Diverges
authorBen Gamari <bgamari.foss@gmail.com>
Wed, 13 Sep 2017 16:22:27 +0000 (12:22 -0400)
committerBen Gamari <ben@smart-cactus.org>
Wed, 13 Sep 2017 20:54:22 +0000 (16:54 -0400)
commit10a1a4781c646f81ca9e2ef7a2585df2cbe3a014
tree8638418f2e91b636c39dc941c7be97a7fcc02968
parent4cead3c1d5bf1c5f3cfb1898fd9d618674292f4b
Model divergence of retry# as ThrowsExn, not Diverges

The demand signature of the retry# primop previously had a Diverges
result.  However, this caused the demand analyser to conclude that a
program of the shape,

    catchRetry# (... >> retry#)

would diverge. Of course, this is plainly wrong; catchRetry#'s sole
reason to exist is to "catch" the "exception" thrown by retry#. While
catchRetry#'s demand signature correctly had the ExnStr flag set on its
first argument, indicating that it should catch divergence, the logic
associated with this flag doesn't apply to Diverges results. This
resulted in #14171.

The solution here is to treat the divergence of retry# as an exception.
Namely, give it a result type of ThrowsExn rather than Diverges.

Updates stm submodule for tests.

Test Plan: Validate with T14171

Reviewers: simonpj, austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #14171, #8091

Differential Revision: https://phabricator.haskell.org/D3919
compiler/basicTypes/Demand.hs
compiler/prelude/primops.txt.pp
libraries/stm