mirror of
https://github.com/unisonweb/unison.git
synced 2024-11-04 01:03:36 +03:00
improved error message a bit
This commit is contained in:
parent
ea113754f6
commit
4490f6318c
@ -423,6 +423,12 @@ renderTypeError e env src = case e of
|
||||
, annotatedAsErrorSite src abilityCheckFailureSite
|
||||
, debugSummary note
|
||||
]
|
||||
UnguardedLetRecCycle vs locs _ -> mconcat
|
||||
[ "These definitions depend on each other cyclically but aren't guarded "
|
||||
, "by a lambda: " <> intercalateMap ", " renderVar vs
|
||||
, "\n"
|
||||
, showSourceMaybes src [ (,ErrorSite) <$> rangeForAnnotated loc | loc <- locs ]]
|
||||
|
||||
UnknownType {..} -> mconcat
|
||||
[ "I don't know about the type "
|
||||
, style ErrorSite (renderVar unknownTypeV)
|
||||
|
@ -60,6 +60,9 @@ data TypeError v loc
|
||||
, abilityCheckFailureSite :: loc
|
||||
, note :: C.ErrorNote v loc
|
||||
}
|
||||
| UnguardedLetRecCycle { cycle :: [v]
|
||||
, cycleLocs :: [loc]
|
||||
, note :: C.ErrorNote v loc }
|
||||
| UnknownType { unknownTypeV :: v
|
||||
, typeSite :: loc
|
||||
, note :: C.ErrorNote v loc
|
||||
@ -94,7 +97,8 @@ typeInfoFromNote n = case n of
|
||||
C.TopLevelComponent defs -> Just $ TopLevelComponent defs
|
||||
_ -> Nothing
|
||||
|
||||
allErrors :: (Var v, Ord loc) => Ex.ErrorExtractor v loc (TypeError v loc)
|
||||
allErrors
|
||||
:: (Var v, Ord loc) => Ex.ErrorExtractor v loc (TypeError v loc)
|
||||
allErrors = asum
|
||||
[ and
|
||||
, or
|
||||
@ -107,6 +111,7 @@ allErrors = asum
|
||||
, applyingNonFunction
|
||||
, generalMismatch
|
||||
, abilityCheckFailure
|
||||
, unguardedCycle
|
||||
, unknownType
|
||||
, unknownTerm
|
||||
]
|
||||
@ -167,6 +172,13 @@ or = booleanMismatch0 OrMismatch (Ex.inSynthesizeApp >> Ex.inOrApp)
|
||||
cond = booleanMismatch0 CondMismatch Ex.inIfCond
|
||||
matchGuard = booleanMismatch0 GuardMismatch Ex.inMatchGuard
|
||||
|
||||
unguardedCycle :: Ex.ErrorExtractor v loc (TypeError v loc)
|
||||
unguardedCycle = do
|
||||
n <- Ex.errorNote
|
||||
C.UnguardedLetRecCycle vs es <- Ex.cause
|
||||
let loc = ABT.annotation . snd <$> es
|
||||
pure $ UnguardedLetRecCycle vs loc n
|
||||
|
||||
-- | helper function to support `and` / `or` / `cond`
|
||||
booleanMismatch0 :: (Var v, Ord loc)
|
||||
=> BooleanMismatch
|
||||
|
@ -4,10 +4,5 @@ y = x + 1
|
||||
|
||||
> x
|
||||
|
||||
---
|
||||
|
||||
Currently crashes the runtime with a
|
||||
|
||||
unison: user error (type error, expecting N, got (UninitializedLetRecSlot x in [y,x]))
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user