Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,248
    • Issues 4,248
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 391
    • Merge Requests 391
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #1904

Closed
Open
Opened Nov 17, 2007 by Ian Lynagh <igloo@earth.li>@trac-igloo

Strictness analyser should be smarter

This module:

module Q (foo) where
foo :: String -> [String] -> Bool
#ifdef FIRST
foo x _ | x `seq` x == "." = True
#else
foo x _ |         x == "." = True
#endif
foo x xs = x `seq` any (x ==) xs

should be compiled to the same code regardless of whether or not FIRST is defined. However, this is not the case; there is an extra case when FIRST is not defined:

$ ghc --version                                              
The Glorious Glasgow Haskell Compilation System, version 6.8.1
$ ghc -fforce-recomp -ddump-simpl -cpp -O -c Q.hs -DFIRST > 1
$ ghc -fforce-recomp -ddump-simpl -cpp -O -c Q.hs > 2
$ diff -U 1000 1 2
--- 1   2007-11-17 21:02:37.000000000 +0000
+++ 2   2007-11-17 21:02:39.000000000 +0000
@@ -1,33 +1,35 @@
 
 ==================== Tidy Core ====================
 Q.a :: GHC.Base.Char
 [GlobalId]
 [NoCafRefs
  Str: DmdType m]
 Q.a = GHC.Base.C# '.'
 
 Q.lvl :: [GHC.Base.Char]
 [GlobalId]
 [NoCafRefs
  Str: DmdType]
 Q.lvl = GHC.Base.: @ GHC.Base.Char Q.a (GHC.Base.[] @ GHC.Base.Char)
 
 Q.foo :: GHC.Base.String -> [GHC.Base.String] -> GHC.Base.Bool
 [GlobalId]
 [Arity 2
  NoCafRefs
  Str: DmdType SL]
 Q.foo =
-  \ (x_a5D :: GHC.Base.String) (ds_d6y :: [GHC.Base.String]) ->
-    case GHC.Base.eqString x_a5D Q.lvl of wild_Xc {
+  \ (x_a5D :: GHC.Base.String) (ds_d6w :: [GHC.Base.String]) ->
+    case GHC.Base.eqString x_a5D Q.lvl of wild_B1 {
       GHC.Base.False ->
-       GHC.List.any @ GHC.Base.String (GHC.Base.eqString x_a5D) ds_d6y;
+       case x_a5D of tpl_Xd { __DEFAULT ->
+       GHC.List.any @ GHC.Base.String (GHC.Base.eqString tpl_Xd) ds_d6w
+       };
       GHC.Base.True -> GHC.Base.True
     }
 
 
 
 
 ==================== Tidy Core Rules ====================
 
 
$

There is a little discussion in the thread where this was first reported: http://www.haskell.org/pipermail/glasgow-haskell-users/2004-June/006862.html

Trac metadata
Trac field Value
Version 6.8.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Unknown
Architecture Unknown
Edited Mar 09, 2019 by Simon Peyton Jones
Assignee
Assign to
⊥
Milestone
⊥
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#1904