Opened 3 years ago

Closed 2 years ago

#9891 closed bug (worksforme)

Fixity declarations for pattern synonyms not persisted

Reported by: klkblake Owned by: cactus
Priority: normal Milestone:
Component: Compiler Version: 7.8.3
Keywords: PatternSynonyms Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

It appears fixity declarations for pattern synonyms only affect modules being compiled in the same run as the module the definition is in. For example, take the following files:

Foo.hs:

{-# LANGUAGE PatternSynonyms #-}
module Foo where

data Type = Type Int RawType

data RawType = Product Type Type
             | Num

pattern a :*: b <- Type _ (Product a b)
infixr 7 :*:

Bar.hs:

{-# LANGUAGE PatternSynonyms #-}
module Main where

import Foo

value = Type 0 $ Product (Type 1 Num) $ Type 2 $ Product (Type 3 Num) $ Type 4 Num

somethingElse = 23

main = case value of
           _ :*: _ :*: _ -> putStrLn "Success"
           _             -> putStrLn "Fail"

On the first compile, the executable will print "Success". Modifying Bar and recompiling will result in it printing "Fail". Modifying both and recompiling results in "Success" again.

Change History (7)

comment:1 Changed 3 years ago by simonpj

Owner: set to cactus

comment:2 Changed 3 years ago by cactus

Keywords: pattern synonyms added

comment:3 Changed 3 years ago by cactus

Keywords: PatternSynonyms added; pattern synonyms removed

comment:4 Changed 3 years ago by cactus

I can't reproduce it on either GHC 7.8.3 or 0ac059:

$ ghc --make Bar.hs 
[1 of 2] Compiling Foo              ( Foo.hs, Foo.o )
[2 of 2] Compiling Main             ( Bar.hs, Bar.o )
Linking Bar ...
$ ./Bar 
Success
$ touch Bar.hs
$ ghc --make Bar.hs
[2 of 2] Compiling Main             ( Bar.hs, Bar.o )
Linking Bar ...
$ ./Bar 
Success
$ ~/prog/haskell/ghc/ghc-build/inplace/bin/ghc-stage2  --make Bar.hs
[1 of 2] Compiling Foo              ( Foo.hs, Foo.o )
[2 of 2] Compiling Main             ( Bar.hs, Bar.o )
WARNING: file compiler/stgSyn/CoreToStg.hs, line 270
  somethingElse True False
Linking Bar ...
$ ./Bar
Success
$ touch Bar.hs 
$ ~/prog/haskell/ghc/ghc-build/inplace/bin/ghc-stage2  --make Bar.hs
[2 of 2] Compiling Main             ( Bar.hs, Bar.o )
WARNING: file compiler/stgSyn/CoreToStg.hs, line 270
  somethingElse True False
Linking Bar ...
$ ./Bar 
Success

comment:5 Changed 3 years ago by cactus

Status: newinfoneeded

comment:6 Changed 3 years ago by klkblake

This is odd. I could reliably reproduce the issue using the testcase three days ago, but now I can no longer reproduce it in both the testcase and the actual program that I was working on when I discovered it. I haven't updated any software or anything. I guess it depended on files left behind from previous incomplete builds, so a clean from scratch build solves it?

comment:7 Changed 2 years ago by cactus

Resolution: worksforme
Status: infoneededclosed
Note: See TracTickets for help on using tickets.