Add support for protected contract calls #732

Merged
zxq9 merged 6 commits from GH-203-protected-calls into master 2020-03-03 00:15:06 +09:00
3 changed files with 29 additions and 2 deletions
Showing only changes of commit e64ac9396a - Show all commits

View File

@ -169,12 +169,13 @@ compilable_contracts() ->
"qualified_constructor", "qualified_constructor",
"let_patterns", "let_patterns",
"lhs_matching", "lhs_matching",
"more_strings" "more_strings",
"protected_call"
]. ].
not_yet_compilable(fate) -> []; not_yet_compilable(fate) -> [];
not_yet_compilable(aevm) -> ["pairing_crypto", "aens_update", "basic_auth_tx", "more_strings", not_yet_compilable(aevm) -> ["pairing_crypto", "aens_update", "basic_auth_tx", "more_strings",
"unapplied_builtins", "bytes_to_x", "state_handling"]. "unapplied_builtins", "bytes_to_x", "state_handling", "protected_call"].
%% Contracts that should produce type errors %% Contracts that should produce type errors
@ -632,6 +633,12 @@ failing_contracts() ->
"Empty record/map update\n" "Empty record/map update\n"
" r {}">> " r {}">>
]) ])
, ?TYPE_ERROR(bad_protected_call,
[<<?Pos(6, 22)
"Invalid 'protected' argument\n"
" (0 : int) == (1 : int) : bool\n"
"It must be either 'true' or 'false'.">>
])
]. ].
-define(Path(File), "code_errors/" ??File). -define(Path(File), "code_errors/" ??File).

View File

@ -0,0 +1,6 @@
contract Remote =
entrypoint id : int => int
contract ProtectedCall =
entrypoint bad(r : Remote) =
r.id(protected = 0 == 1, 18)

View File

@ -0,0 +1,14 @@
contract Remote =
entrypoint id : int => int
contract ProtectedCall =
function higher_order(r : Remote) =
r.id
entrypoint test_ok(r : Remote) =
let f = higher_order(r)
let Some(n) = r.id(protected = true, 10)
let Some(m) = f(protected = true, 5)
n + m + r.id(protected = false, 100) + f(1)