Skip to content

Commit 2e42b36

Browse files
joelburgetbts
authored andcommitted
Propagate location info through translation.
1 parent e4bbe45 commit 2e42b36

File tree

3 files changed

+126
-101
lines changed

3 files changed

+126
-101
lines changed

‎src/Pact/Analyze/Check.hs‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ data CheckFailureNoLoc
106106
| SmtFailure SmtFailure
107107
deriving (Eq, Show)
108108

109+
-- TODO: change Parsed to Info if possible
109110
data CheckFailure = CheckFailure
110111
{ _checkFailureParsed :: !Parsed
111112
, _checkFailure :: !CheckFailureNoLoc
@@ -160,8 +161,8 @@ describeCheckResult :: CheckResult -> Text
160161
describeCheckResult = either describeCheckFailure describeCheckSuccess
161162

162163
translateToCheckFailure :: TranslateFailure -> CheckFailure
163-
translateToCheckFailure (TranslateFailure parsed err)
164-
= CheckFailure parsed (TranslateFailure' err)
164+
translateToCheckFailure (TranslateFailure info err)
165+
= CheckFailure (getInfoParsed info) (TranslateFailure' err)
165166

166167
analyzeToCheckFailure :: AnalyzeFailure -> CheckFailure
167168
analyzeToCheckFailure (AnalyzeFailure parsed err)
@@ -396,9 +397,7 @@ checkFunctionInvariants
396397
-> IO (Either CheckFailure (TableMap [CheckResult]))
397398
checkFunctionInvariants tables info pactArgs body = runExceptT $ do
398399
(args, tm, tagAllocs) <- hoist generalize $
399-
-- TODO: runTranslation would ideally give us info about exactly where
400-
-- the translation failed. This is as close as we can get currently.
401-
withExcept translateToCheckFailure $ runTranslation pactArgs body
400+
withExcept translateToCheckFailure $ runTranslation info pactArgs body
402401

403402
ExceptT $ catchingExceptions $ runSymbolic $ runExceptT $ do
404403
tags <- lift $ allocModelTags info args tm tagAllocs
@@ -465,7 +464,7 @@ checkFunction
465464
checkFunction tables info parsed pactArgs body check = runExceptT $ do
466465
(args, tm, tagAllocs) <- hoist generalize $
467466
withExcept translateToCheckFailure $
468-
runTranslation pactArgs body
467+
runTranslation info pactArgs body
469468

470469
ExceptT $ catchingExceptions $ runSymbolic $ runExceptT $ do
471470
tags <- lift $ allocModelTags info args tm tagAllocs

0 commit comments

Comments
 (0)