llvm-hs / llvm-hs-pretty

Pretty printer for LLVM AST to Textual IR
MIT License
67 stars 37 forks source link

I don't think hackage is up to date for this package... #66

Closed sebeaumont closed 5 years ago

sebeaumont commented 5 years ago

Something weird but I got an error building this package as a dependency from Hackage... and I just cabal updated -- building from the head was ok, but package version seems the same in both cases.

Anyway the error was:

Building library for llvm-hs-pretty-0.5.0.0..
[1 of 2] Compiling LLVM.Pretty      ( src/LLVM/Pretty.hs, dist/build/LLVM/Pretty.o )

src/LLVM/Pretty.hs:852:10: error:
    Not in scope: data constructor ‘None’
    |
852 |   pretty None = "CSK_None"
    |          ^^^^

But that has gone away if I build this package from the head (should there be a version bump?) I got a bunch of incomplete-uni-patterns warnings but it all seems to work.

I'm using ghc --version The Glorious Glasgow Haskell Compilation System, version 8.4.4 on OSX if that's any help and cabal new-* cabal --version cabal-install version 2.4.0.0 compiled using version 2.4.0.1 of the Cabal library sans stack -- which might be a problem?

sdiehl commented 5 years ago

You are right, I have to upload it again.

sdiehl commented 5 years ago

Here is the updated package:

https://hackage.haskell.org/package/llvm-hs-pretty-0.6.0.0

sebeaumont commented 5 years ago

Hmm... looks like that tarball has the wrong source code... I still get the same error

Building library for llvm-hs-pretty-0.6.0.0..
[1 of 2] Compiling LLVM.Pretty      ( src/LLVM/Pretty.hs, dist/build/LLVM/Pretty.o )

src/LLVM/Pretty.hs:852:10: error:
    Not in scope: data constructor ‘None’
    |
852 |   pretty None = "CSK_None"
    |          ^^^^
cabal: Failed to build llvm-hs-pretty-0.6.0.0

And if I look into the package source code for Pretty.hs, sure enough it looks different to the head.

diff Pretty.hs ./llvm-hs-pretty/src/LLVM/Pretty.hs
693c693,697
<   pretty (Enumerator val name) = ppDINode "DIEnumerator" [("name", ppSbs name), ("value", Just (pretty val))]
---
>   pretty (Enumerator val unsigned name) =
>     ppDINode "DIEnumerator"
>       [ ("name", ppSbs name)
>       , ("isUnsigned", if unsigned then Just "true" else Nothing)
>       , ("value", Just (pretty val))]
730a735,738
> instance Pretty DICount where
>   pretty (DICountConstant c) = pretty c
>   pretty (DICountVariable v) = pretty v
>
780,781d787
<     , ("checksum", ppSbs checksum)
<     , ("checksumkind", Just (pretty checksumKind))
782a789,793
>     <> ppDIChecksum checksum
>
> ppDIChecksum :: Maybe ChecksumInfo -> [([Char], Maybe (Doc ann))]
> ppDIChecksum Nothing = []
> ppDIChecksum (Just (ChecksumInfo kind val)) = [("checksumkind", Just (pretty kind)), ("checksum", ppSbs val)]
842c853
<    , ("variables", ppDIArray (map pretty variables))
---
>    , ("retainedNodes", ppDIArray (map pretty retainedNodes))
852d862
<   pretty None = "CSK_None"
sebeaumont commented 5 years ago

Maybe you want to squash these warnings as well:

Building library for llvm-hs-pretty-0.6.0.0..
[1 of 2] Compiling LLVM.Pretty      ( src/LLVM/Pretty.hs, /Users/seb/Dev/hilbert/hilbert-hask/dist-newstyle/build/x86_64-osx/ghc-8.4.4/llvm-hs-pretty-0.6.0.0/build/LLVM/Pretty.o )

src/LLVM/Pretty.hs:530:13: warning: [-Wincomplete-uni-patterns]
    Pattern match(es) are non-exhaustive
    In a pattern binding:
        Patterns not matched:
            VoidType
            (IntegerType _)
            (FloatingPointType _)
            (FunctionType _ _ _)
            ...
    |
530 |       where PointerType argTy _ = typeOf address
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/LLVM/Pretty.hs:1110:7: warning: [-Wincomplete-uni-patterns]
    Pattern match(es) are non-exhaustive
    In a pattern binding:
        Patterns not matched:
            VoidType
            (IntegerType _)
            (FloatingPointType _)
            (FunctionType _ _ _)
            ...
     |
1110 |       PointerType argTy _ = typeOf address
     |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/LLVM/Pretty.hs:1265:7: warning: [-Wincomplete-uni-patterns]
    Pattern match(es) are non-exhaustive
    In a pattern binding:
        Patterns not matched:
            VoidType
            (IntegerType _)
            (PointerType _ _)
            (FloatingPointType _)
            ...
     |
1265 |       (functionType@FunctionType {..}) = referencedType (typeOf f)
     |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/LLVM/Pretty.hs:1305:7: warning: [-Wincomplete-uni-patterns]
    Pattern match(es) are non-exhaustive
    In a pattern binding:
        Patterns not matched:
            VoidType
            (IntegerType _)
            (PointerType _ _)
            (FloatingPointType _)
            ...
     |
1305 |       (functionType@FunctionType {..}) = referencedType (typeOf f)
     |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sdiehl commented 5 years ago

I think this issue should be closed. It should be fine now.