Skip to content

-XStrict language extension makes behavior change

In the below code without language pragma it prints 0, and it is expected.

With language pragma, it doesn't terminate. I don't know whether it is intended to evaluate unnecessary where term and why it doesn't terminate.

{-# LANGUAGE Strict #-}

shouldBe0 :: Int -> Int
shouldBe0 l = if l <= 0 then l else shouldBe0 (l - 1)
  where res = shouldBe0 (l - 1)

main :: IO ()
main = print $ shouldBe0 1
Trac metadata
Trac field Value
Version 8.2.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information