Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specs not exported from preprocessed source code #2132

Open
mboes opened this issue Jan 1, 2023 · 3 comments
Open

Specs not exported from preprocessed source code #2132

mboes opened this issue Jan 1, 2023 · 3 comments

Comments

@mboes
Copy link
Contributor

mboes commented Jan 1, 2023

Consider the following example, where the source for the A module is preprocessed with hsc2hs:

# A.hsc
module A where

{-@ type Foo = { v : Int | v = 5 } @-}

# B.hs
module B where

import A

{-@ foo :: Foo @-}
foo = 5

LH fails with the following error:

[1 of 2] Compiling A

**** LIQUID: SAFE (0 constraints checked) **************************************
[2 of 2] Compiling B
ghc: panic! (the 'impossible' happened)
  (GHC version 8.10.7:
	[src/B.hs:5:12-14 Unknown type constructor `Foo`
                     matchTyCon: Foo]

If A.hsc is renamed to A.hs instead, then everything works fine. This problem might be hsc2hs-specific, but I suspect it's a more general problem with preprocessed source code.

Version of LH used: 0.8.10.7 (latest release on Hackage at time of writing)

@facundominguez
Copy link
Collaborator

facundominguez commented Jan 1, 2023

I can't reproduce in the latest version of LH from github. Also, the program needs to add a type signature for foo, otherwise GHC infers Integer instead of Int.

@mboes
Copy link
Contributor Author

mboes commented Jan 2, 2023

I'm not claiming that the code satisfies the spec, but I'm claiming that the spec is not made available to downstream modules. I can reproduce even with HEAD. See https://github.com/mboes/liquidhaskell-issue-2132.

facundominguez added a commit to tweag/HaskellR that referenced this issue Apr 26, 2023
Liquid Haskell can't collect specs in .hsc files.
See ucsd-progsys/liquidhaskell#2132
facundominguez added a commit to tweag/HaskellR that referenced this issue Oct 25, 2023
Liquid Haskell can't collect specs in .hsc files.
See ucsd-progsys/liquidhaskell#2132
facundominguez added a commit to tweag/HaskellR that referenced this issue Dec 7, 2023
Liquid Haskell can't collect specs in .hsc files.
See ucsd-progsys/liquidhaskell#2132
facundominguez added a commit to tweag/HaskellR that referenced this issue Jan 8, 2024
Liquid Haskell can't collect specs in .hsc files.
See ucsd-progsys/liquidhaskell#2132
facundominguez added a commit to tweag/HaskellR that referenced this issue Jan 10, 2024
Liquid Haskell can't collect specs in .hsc files.
See ucsd-progsys/liquidhaskell#2132
facundominguez added a commit to tweag/HaskellR that referenced this issue Jan 18, 2024
Liquid Haskell can't collect specs in .hsc files.
See ucsd-progsys/liquidhaskell#2132
facundominguez added a commit to tweag/HaskellR that referenced this issue Jan 19, 2024
Liquid Haskell can't collect specs in .hsc files.
See ucsd-progsys/liquidhaskell#2132
facundominguez added a commit to tweag/HaskellR that referenced this issue Jan 24, 2024
Liquid Haskell can't collect specs in .hsc files.
See ucsd-progsys/liquidhaskell#2132
@facundominguez
Copy link
Collaborator

I'm reproducing with the OPTIONS_GHC pragma.

# A.hsc
{-# OPTIONS_GHC -fplugin=LiquidHaskell #-}
module A where
{-@ type Foo = { v : Integer | v = 5 } @-}

# B.hs
{-# OPTIONS_GHC -fplugin=LiquidHaskell #-}
module B where
import A
{-@ foo :: Foo @-}
foo = 5

#hsctest.cabal
cabal-version:      2.4
name:               hsctest
version:            0.1
synopsis:           Test for LiquidHaskell + hsc2hs
build-type:         Simple

library
  exposed-modules:    A B

  build-depends:      base                 >= 4.11.1.0 && < 5,
                      liquidhaskell        == 0.9.8.1
  default-language:   Haskell98
  ghc-options:        -Wall

hsc2hs produces the following file

{-# LINE 1 "hsctest/A.hs" #-}
{-# OPTIONS_GHC -fplugin=LiquidHaskell #-}
module A where

{-@ type Foo = { v : Integer | v = 5 } @-}

Removing the LINE pragma causes the definition of Foo to be found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants