Skip to content

cabal from master doesn't re-run preprocessing when file changes #11810

@sergv

Description

@sergv

Describe the bug
I have .hsc file, it doesn't compile from clean build. I edit the file fixing the error but it still doesn't compile with the same error because cabal doesn't re-run preprocessing since #10534.

To Reproduce
Please refer to readme at https://github.com/random-random-stuff/simple-cabal-project-with-hsc.

  1. Initial version doesn’t compile
$ cabal build
...
[1 of 2] Compiling Bar.Baz
src/Bar/Baz.hsc:18:9: error: [GHC-25897]
• Couldn't match expected type ‘a’ with actual type ‘CDoubleTyp’
  Type synonyms expanded:
  Expected type: a
    Actual type: Double
  ‘a’ is a rigid type variable bound by
    the type signature for:
      baz :: forall a. Double -> a
    at src/Bar/Baz.hsc:17:1-18
• In the expression: sinFunc x
  In an equation for ‘baz’: baz x = sinFunc x
• Relevant bindings include
    baz :: Double -> a (bound at src/Bar/Baz.hsc:18:1)
|
18 | baz x = sinFunc x
|         ^^^^^^^^^
...
  1. Fix
$ sed -i -re 's,baz :: Double -> a,baz :: Double -> CDoubleTyp,' src/Bar/Baz.hsc
  1. Try to build again
cabal build
...
[1 of 2] Compiling Bar.Baz
src/Bar/Baz.hsc:18:9: error: [GHC-25897]
• Couldn't match expected type ‘a’ with actual type ‘CDoubleTyp’
  Type synonyms expanded:
  Expected type: a
    Actual type: Double
  ‘a’ is a rigid type variable bound by
    the type signature for:
      baz :: forall a. Double -> a
    at src/Bar/Baz.hsc:17:1-18
• In the expression: sinFunc x
  In an equation for ‘baz’: baz x = sinFunc x
• Relevant bindings include
    baz :: Double -> a (bound at src/Bar/Baz.hsc:18:1)
|
18 | baz x = sinFunc x
|         ^^^^^^^^^
...

Same error because cabal didn’t re-run preprocessing on src/Bar/Baz.hsc

Just before the PR it was OK, but now cabal sees that Baz.hs file and doesn't check that its source is newer and it should be regenerated.

Expected behavior
Modification of .hsc file leads to regeneration of the corresponding .hs file.

System information

  • Operating system Linux
  • cabal version - master
  • ghc version - 9.14

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions