mirror of
https://github.com/digital-asset/daml.git
synced 2024-11-09 15:37:05 +03:00
Add serializability check for exceptions. (#8151)
* Add serializability check for exceptions. Part of #8020 changelog_begin changelog_end * typo
This commit is contained in:
parent
ab43da3f7a
commit
84e5881236
@ -46,6 +46,7 @@ data SerializabilityRequirement
|
||||
| SRChoiceRes
|
||||
| SRKey
|
||||
| SRDataType
|
||||
| SRExceptionArg
|
||||
|
||||
-- | Reason why a type is not serializable.
|
||||
data UnserializabilityReason
|
||||
@ -170,6 +171,7 @@ instance Pretty SerializabilityRequirement where
|
||||
SRChoiceRes -> "choice result"
|
||||
SRDataType -> "serializable data type"
|
||||
SRKey -> "template key"
|
||||
SRExceptionArg -> "exception argument"
|
||||
|
||||
instance Pretty UnserializabilityReason where
|
||||
pPrint = \case
|
||||
|
@ -163,6 +163,12 @@ checkTemplate mod0 tpl = do
|
||||
for_ (tplKey tpl) $ \key -> withContext (ContextTemplate mod0 tpl TPKey) $ do
|
||||
checkType SRKey (tplKeyType key)
|
||||
|
||||
-- | Check whether exception is serializable.
|
||||
checkException :: MonadGamma m => Module -> DefException -> m ()
|
||||
checkException mod0 exn = do
|
||||
let tcon = Qualified PRSelf (moduleName mod0) (exnName exn)
|
||||
checkType SRExceptionArg (TCon tcon)
|
||||
|
||||
-- | Check whether a module satisfies all serializability constraints.
|
||||
checkModule :: MonadGamma m => Module -> m ()
|
||||
checkModule mod0 = do
|
||||
@ -172,3 +178,6 @@ checkModule mod0 = do
|
||||
for_ (moduleTemplates mod0) $ \tpl ->
|
||||
withContext (ContextTemplate mod0 tpl TPWhole) $
|
||||
checkTemplate mod0 tpl
|
||||
for_ (moduleExceptions mod0) $ \exn ->
|
||||
withContext (ContextDefException mod0 exn) $
|
||||
checkException mod0 exn
|
||||
|
Loading…
Reference in New Issue
Block a user