mirror of
https://github.com/ilyakooo0/ormolu.git
synced 2024-10-27 03:28:33 +03:00
Avoid crashing on unboxed string literals
This commit is contained in:
parent
bdb22b96ac
commit
f86e01ea3b
@ -0,0 +1,3 @@
|
||||
{-# LANGUAGE MagicHash #-}
|
||||
|
||||
main = new "p"#
|
@ -0,0 +1,3 @@
|
||||
{-# LANGUAGE MagicHash #-}
|
||||
|
||||
main = new "p"#
|
@ -38,6 +38,7 @@ flag dev
|
||||
library
|
||||
hs-source-dirs: src
|
||||
build-depends: base >= 4.12 && < 5.0
|
||||
, bytestring >= 0.2 && < 0.11
|
||||
, containers >= 0.5 && < 0.7
|
||||
, dlist >= 0.8 && < 0.9
|
||||
, exceptions >= 0.6 && < 0.11
|
||||
|
@ -11,6 +11,7 @@ module Ormolu.Diff
|
||||
where
|
||||
|
||||
import BasicTypes (SourceText)
|
||||
import Data.ByteString (ByteString)
|
||||
import Data.Generics
|
||||
import GHC
|
||||
import Ormolu.Imports (sortImports)
|
||||
@ -51,6 +52,12 @@ matchIgnoringSrcSpans = genericQuery
|
||||
where
|
||||
genericQuery :: GenericQ (GenericQ Diff)
|
||||
genericQuery x y
|
||||
-- NOTE 'ByteString' implement 'Data' instance manually and does not
|
||||
-- implement 'toConstr', so we have to deal with it in a special way.
|
||||
| Just x' <- cast x, Just y' <- cast y =
|
||||
if x' == (y' :: ByteString)
|
||||
then Same
|
||||
else Different []
|
||||
| typeOf x == typeOf y, toConstr x == toConstr y =
|
||||
mconcat $ gzipWithQ
|
||||
(genericQuery
|
||||
|
Loading…
Reference in New Issue
Block a user