diff --git a/pact-tests/Pact/Core/Test/PactContinuationTest.hs b/pact-tests/Pact/Core/Test/PactContinuationTest.hs index 1eae0ce6..af955067 100644 --- a/pact-tests/Pact/Core/Test/PactContinuationTest.hs +++ b/pact-tests/Pact/Core/Test/PactContinuationTest.hs @@ -120,7 +120,7 @@ testManagedCaps = do let allCmds = [sysModuleCmd,acctModuleCmd,createAcctCmd,managedPay,managedPayFails] allResults <- runAll allCmds - mhash <- mkModuleHash "PkJ6B966fhCGDEWeTfbfP78btLEfM9SpjButLlA4Lj4" + mhash <- mkModuleHash "xkYy5KYtEkV1WFZ791iCnZjRBx6um5FEe1aU-rPCOv8" runResults allResults $ do sysModuleCmd `succeedsWith` (`shouldBe` textVal "system module loaded") diff --git a/pact-tests/pact-tests/object-evaluation-order-regression.repl b/pact-tests/pact-tests/object-evaluation-order-regression.repl new file mode 100644 index 00000000..9404d0b8 --- /dev/null +++ b/pact-tests/pact-tests/object-evaluation-order-regression.repl @@ -0,0 +1,29 @@ +;; Regression for https://github.com/kadena-io/pact-5/issues/260 + +(module my-mod G + @doc "A simple module that manages a counter" + (defcap G() true) + + (defschema counter-schema + cnt:integer) + + (deftable counter-table:{counter-schema}) + + (defun init:string () + @doc "Initialize the counter" + (insert counter-table "SINGLETON" {'cnt:0}) + ) + + (defun increment:integer () + @doc "Increment the counter and return the old value" + (with-read counter-table "SINGLETON" {'cnt:=old-value} + (update counter-table "SINGLETON" {'cnt:(+ 1 old-value)}) + old-value) + ) + +) +; Init the counter +(create-table counter-table) +(my-mod.init) + +(expect "check evaluation order from left to right" {'a:(my-mod.increment), 'b:(my-mod.increment), 'c:(my-mod.increment)} {'a: 0, 'b:1, 'c:2}) \ No newline at end of file diff --git a/pact/Pact/Core/Syntax/Parser.y b/pact/Pact/Core/Syntax/Parser.y index 9dd0d52e..d23478a9 100644 --- a/pact/Pact/Core/Syntax/Parser.y +++ b/pact/Pact/Core/Syntax/Parser.y @@ -434,7 +434,7 @@ Object :: { ParsedExpr } : '{' ObjectBody '}' { Object $2 (combineSpan (_ptInfo $1) (_ptInfo $3)) } ObjectBody :: { [(Field, ParsedExpr)] } - : FieldPairs { $1 } + : FieldPairs { reverse $1 } FieldPair :: { (Field, ParsedExpr) } : STR ':' Expr { (Field (getStr $1), $3) }