Skip to content

Commit

Permalink
Flag to disable return RTC, 4.7.1 release prep (#1231)
Browse files Browse the repository at this point in the history
* Revert "[FORK] Add runtime type check for function return types (#1209)"

This reverts commit a33ebb8.

* rep 4.7.1 release

* add runtime return tc flag `DisableReturnRTC`

* update CHANGELOG.md

* Reverse direction of feature flag

* fix haddock

* Revert "fix haddock"

This reverts commit 503e083.

* Revert "Reverse direction of feature flag"

This reverts commit 2127f79.

* address comments

* address missing newline

* unambiguous name

* Update tests/pact/tc.repl

Co-authored-by: Stuart Popejoy <8353613+sirlensalot@users.noreply.github.com>

---------

Co-authored-by: Emily Pillmore <emily@kadena.io>
Co-authored-by: Stuart Popejoy <8353613+sirlensalot@users.noreply.github.com>
  • Loading branch information
3 people committed May 20, 2023
1 parent b36ef3e commit 456aa65
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 7 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
4.7.1
---

- Add feature flag `FlagDisableRuntimeTypeChecking` for disabling runtime typechecking
introduced in Pact 4.7 (#1231)

### Formal Verification

- Fixed empty list type defaulting to any (#1224)
- Fixed partial biniding (#1127)

### Tests

- Refactored test to avoid `runIO` within tests (#1129)
- Add `CoverageSpec` (#1228)
- Fix `ReplSpec` tests (#1216)
- Cleanup `PactContinuationSpec` (#1222)

### Others

- Cleanup [README.md](README.md) (#1225)
- Bump Z3 versions in GH actions (#1126)

4.7.0
---

Expand Down
4 changes: 2 additions & 2 deletions docs/en/pact-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ Return ID if called during current pact execution, failing if not.
Obtain current pact build version.
```lisp
pact> (pact-version)
"4.7.0"
"4.7.1"
```

Top level only: this function will fail if used in module code.
Expand Down Expand Up @@ -1928,7 +1928,7 @@ Retreive any accumulated events and optionally clear event state. Object returne
*&rarr;*&nbsp;`[string]`


Queries, or with arguments, sets execution config flags. Valid flags: ["AllowReadInLocal","DisableHistoryInTransactionalMode","DisableInlineMemCheck","DisableModuleInstall","DisableNewTrans","DisablePact40","DisablePact420","DisablePact43","DisablePact431","DisablePact44","DisablePact45","DisablePact46","DisablePact47","DisablePactEvents","EnforceKeyFormats","OldReadOnlyBehavior","PreserveModuleIfacesBug","PreserveModuleNameBug","PreserveNsModuleInstallBug","PreserveShowDefs"]
Queries, or with arguments, sets execution config flags. Valid flags: ["AllowReadInLocal","DisableHistoryInTransactionalMode","DisableInlineMemCheck","DisableModuleInstall","DisableNewTrans","DisablePact40","DisablePact420","DisablePact43","DisablePact431","DisablePact44","DisablePact45","DisablePact46","DisablePact47","DisablePactEvents","DisableRuntimeReturnTypeChecking","EnforceKeyFormats","OldReadOnlyBehavior","PreserveModuleIfacesBug","PreserveModuleNameBug","PreserveNsModuleInstallBug","PreserveShowDefs"]
```lisp
pact> (env-exec-config ['DisableHistoryInTransactionalMode]) (env-exec-config)
["DisableHistoryInTransactionalMode"]
Expand Down
2 changes: 1 addition & 1 deletion examples/cp/orders.pact
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

)

(defun with-order-status (order-id status)
(defun with-order-status:object{order} (order-id status)
"Check that order status is correct, returning details"
(let ((o (read orders order-id)))
(enforce (= (at 'status o) status)
Expand Down
2 changes: 1 addition & 1 deletion pact.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.2
name: pact
version: 4.7.0
version: 4.7.1
-- ^ 4 digit is prerelease, 3- or 2-digit for prod release
synopsis: Smart contract language library and REPL
description:
Expand Down
2 changes: 1 addition & 1 deletion src/Pact/Eval.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ functionApp fnName funTy mod_ as fnBody docs ai = do

returnVal <- guardRecursion fname mod_ $ appCall fa ai args' $ fmap (gas,) $ reduceBody body

unlessExecutionFlagSet FlagDisablePact47 $
unlessExecutionFlagSet FlagDisableRuntimeReturnTypeChecking $
typecheckTerm ai (_ftReturn fty) returnVal

return returnVal
Expand Down
2 changes: 2 additions & 0 deletions src/Pact/Types/Runtime.hs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ data ExecutionFlag
| FlagDisablePact46
-- | Disable Pact 4.7 Features
| FlagDisablePact47
-- | Disable runtime return type checking.
| FlagDisableRuntimeReturnTypeChecking
deriving (Eq,Ord,Show,Enum,Bounded)

-- | Flag string representation
Expand Down
5 changes: 3 additions & 2 deletions tests/pact/tc.repl
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@

;; A module with incorrect annotations for a function's return type.
;; Runtime typechecking for function return types was added in
;; pact-4.7.
;; pact-4.7.1 and guarded via `DisableRuntimeReturnTypeChecking`.

(module tc-test-function-return-types g
(defcap g () true)
(defun f:string () (+ 1 2))
Expand All @@ -387,7 +388,7 @@
(tc-test-function-return-types.g (tc-test-function-return-types.f 1))
)

(env-exec-config ["DisablePact47"])
(env-exec-config ["DisableRuntimeReturnTypeChecking"])
(expect
"evaluating ill-typed function should succeed with pact-4.7 features disabled"
3
Expand Down

0 comments on commit 456aa65

Please sign in to comment.