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

chore: make missing records fields an error for cryptol-remote-api #1088

Merged
merged 1 commit into from
Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions cryptol-remote-api/cryptol-remote-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data-files: test-scripts/**/*.py

common warnings
ghc-options:
-Weverything
-Wall
-Wno-missing-exported-signatures
-Wno-missing-import-lists
-Wno-missed-specialisations
Expand All @@ -24,6 +24,12 @@ common warnings
-Wno-implicit-prelude
-Wno-missing-deriving-strategies

common errors
ghc-options:
-Werror=missing-fields
-Werror=incomplete-patterns
-Werror=missing-methods
-Werror=overlapping-patterns

common deps
build-depends:
Expand All @@ -46,7 +52,7 @@ common deps
default-language: Haskell2010

library
import: deps, warnings
import: deps, warnings, errors
hs-source-dirs: src

exposed-modules:
Expand All @@ -65,7 +71,7 @@ library
CryptolServer.TypeCheck

executable cryptol-remote-api
import: deps, warnings
import: deps, warnings, errors
main-is: Main.hs
hs-source-dirs: cryptol-remote-api
ghc-options:
Expand All @@ -76,7 +82,7 @@ executable cryptol-remote-api
sbv < 8.10

executable cryptol-eval-server
import: deps, warnings
import: deps, warnings, errors
main-is: Main.hs
hs-source-dirs: cryptol-eval-server
ghc-options:
Expand All @@ -89,7 +95,7 @@ executable cryptol-eval-server


test-suite test-cryptol-remote-api
import: deps, warnings
import: deps, warnings, errors
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Test.hs
Expand Down
21 changes: 12 additions & 9 deletions cryptol-remote-api/src/CryptolServer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import Cryptol.Eval (EvalOpts(..))
import Cryptol.ModuleSystem (ModuleCmd, ModuleEnv, ModuleInput(..))
import Cryptol.ModuleSystem.Env
(getLoadedModules, lmFilePath, lmFingerprint, meLoadedModules,
initialModuleEnv, meSearchPath, ModulePath(..))
import Cryptol.ModuleSystem.Fingerprint
initialModuleEnv, meSearchPath, ModulePath(..), meSolverConfig)
import Cryptol.ModuleSystem.Fingerprint ( fingerprintFile )
import Cryptol.Parser.AST (ModName)
import qualified Cryptol.TypeCheck.Solver.SMT as SMT

import qualified Argo
import qualified Argo.Doc as Doc
Expand Down Expand Up @@ -61,13 +62,15 @@ runModuleCmd cmd =
do Options callStacks evOpts <- getOptions
s <- CryptolMethod $ const Argo.getState
reader <- CryptolMethod $ const Argo.getFileReader
let minp = ModuleInput
{ minpCallStacks = callStacks
, minpEvalOpts = pure evOpts
, minpByteReader = reader
, minpModuleEnv = view moduleEnv s
}
out <- liftIO $ cmd minp
let minp solver = ModuleInput
{ minpCallStacks = callStacks
, minpEvalOpts = pure evOpts
, minpByteReader = reader
, minpModuleEnv = view moduleEnv s
, minpTCSolver = solver
}
let solverCfg = meSolverConfig (view moduleEnv s)
out <- liftIO $ SMT.withSolver solverCfg (cmd . minp)
case out of
(Left x, warns) ->
raise (cryptolError x warns)
Expand Down