Bind state and event primitives only in contracts (and with the right types)

This commit is contained in:
Ulf Norell
2019-02-04 18:28:46 +01:00
parent d9188d58a7
commit e6f01481bf
3 changed files with 42 additions and 25 deletions
+3 -1
View File
@@ -76,7 +76,9 @@ compilable_contracts() ->
"builtin_map_get_bug",
"nodeadcode",
"deadcode",
"variant_types"
"variant_types",
"state_handling",
"events"
].
%% Contracts that should produce type errors
+13 -10
View File
@@ -1,19 +1,22 @@
contract Remote =
function look_at : (state) => ()
record rstate = { i : int, s : string, m : map(int, int) }
function look_at : (rstate) => ()
function return_s : (bool) => string
function return_m : (bool) => map(int, int)
function get : (state) => state
function get_i : (state) => int
function get_s : (state) => string
function get_m : (state) => map(int, int)
function get : (rstate) => rstate
function get_i : (rstate) => int
function get_s : (rstate) => string
function get_m : (rstate) => map(int, int)
function fun_update_i : (state, int) => state
function fun_update_s : (state, string) => state
function fun_update_m : (state, map(int, int)) => state
function fun_update_mk : (state, int, int) => state
function fun_update_i : (rstate, int) => rstate
function fun_update_s : (rstate, string) => rstate
function fun_update_m : (rstate, map(int, int)) => rstate
function fun_update_mk : (rstate, int, int) => rstate
contract StateHandling =
record state = { i : int, s : string, m : map(int, int) }
type state = Remote.rstate
function init(r : Remote, i : int) =
let state0 = { i = 0, s = "undefined", m = {} }