Skip to content

Commit

Permalink
Add some text to the <<loop>> error.
Browse files Browse the repository at this point in the history
Explain that the error might occur because of retrying an
interrupted computation and suggest that reloading might
alleviate the issue.

Fixes #1030
  • Loading branch information
robdockins committed Feb 12, 2021
1 parent bcc7612 commit a370cd0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/Cryptol/Backend/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,12 @@ instance PP EvalError where
NegativeExponent -> text "negative exponent"
LogNegative -> text "logarithm of negative"
UserError x -> text "Run-time error:" <+> text x
LoopError x -> text "<<loop>>" <+> text x
LoopError x -> vcat [ text "<<loop>>" <+> text x
, text "This ususually occurs due to an improper recursive definition,"
, text "but may also result from retrying a previously interrupted a"
, text "computation (e.g., after CTRL^C). In that case, you may need to"
, text "`:reload` the current module to reset to a good state."
]
BadRoundingMode r -> "invalid rounding mode" <+> integer r
BadValue x -> "invalid input for" <+> backticks (text x)
NoPrim x -> text "unimplemented primitive:" <+> pp x
Expand Down
7 changes: 3 additions & 4 deletions src/Cryptol/TypeCheck/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ instance PP (WithNames Error) where

TooManyPositionalTypeParams ->
addTVarsDescsAfter names err $
"Too many positional type-parameters in explicit type application"
"Too many positional type-parameters in explicit type application."

CannotMixPositionalAndNamedTypeParams ->
addTVarsDescsAfter names err $
Expand Down Expand Up @@ -475,7 +475,7 @@ explainUnsolvable names gs =
PPrime -> useCtr

PHas sel ->
custom ("Type" <+> doc1 <+> "does not have field" <+> f
custom ("Type" <+> doc1 <+> "does not have field" <+> f
<+> "of type" <+> (tys !! 1))
where f = case sel of
P.TupleSel n _ -> int n
Expand Down Expand Up @@ -544,7 +544,7 @@ computeFreeVarNames warns errs =

{- XXX: Currently we pick the names based on the unique of the variable:
smaller uniques get an earlier name (e.g., 100 might get `a` and 200 `b`)
This may still lead to changes in the names if the uniques got reordred
This may still lead to changes in the names if the uniques got reordered
for some reason. A more stable approach might be to order the variables
on their location in the error/warning, but that's quite a bit more code
so for now we just go with the simple approximation. -}
Expand All @@ -570,4 +570,3 @@ computeFreeVarNames warns errs =
variant n x = if n == 0 then x else x ++ suff n

variants roots = [ variant n r | n <- [ 0 .. ], r <- roots ]

0 comments on commit a370cd0

Please sign in to comment.