@@ -8,6 +8,7 @@ module Dhall.Freeze
88 , hashImport
99 ) where
1010
11+ import Control.Exception (SomeException )
1112import Data.Monoid ((<>) )
1213import Data.Maybe (fromMaybe )
1314import Data.Text
@@ -16,6 +17,7 @@ import Dhall.Core (Expr(..), Import(..), ImportHashed(..))
1617import Dhall.Import (standardVersion )
1718import Dhall.Parser (exprAndHeaderFromText , Src )
1819import Dhall.Pretty (annToAnsiStyle , layoutOpts )
20+ import Dhall.TypeCheck (X )
1921import Lens.Family (set )
2022import System.Console.ANSI (hSupportsANSI )
2123
@@ -38,9 +40,24 @@ hashImport
3840 -> Import
3941 -> IO Import
4042hashImport directory _standardVersion import_ = do
43+ let unprotectedImport =
44+ import_
45+ { importHashed =
46+ (importHashed import_)
47+ { hash = Nothing
48+ }
49+ }
4150 let status = set standardVersion _standardVersion (Dhall.Import. emptyStatus directory)
4251
43- expression <- State. evalStateT (Dhall.Import. loadWith (Embed import_)) status
52+ let download =
53+ State. evalStateT (Dhall.Import. loadWith (Embed import_)) status
54+
55+ -- Try again without the semantic integrity check if decoding fails
56+ let handler :: SomeException -> IO (Expr Src X )
57+ handler _ = do
58+ State. evalStateT (Dhall.Import. loadWith (Embed unprotectedImport)) status
59+
60+ expression <- Control.Exception. handle handler download
4461
4562 case Dhall.TypeCheck. typeOf expression of
4663 Left exception -> Control.Exception. throwIO exception
0 commit comments