From a0ffc441f34a030dd2fa2395c4e20a2b90bb8274 Mon Sep 17 00:00:00 2001 From: Sander Spies Date: Mon, 3 Feb 2020 11:25:13 +0100 Subject: [PATCH] Forgot to add these. --- .../docs/advanced/entrypoints-contracts.md | 3 +- src/test/contracts/negative/gitlab_111.religo | 58 +++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 src/test/contracts/negative/gitlab_111.religo diff --git a/gitlab-pages/docs/advanced/entrypoints-contracts.md b/gitlab-pages/docs/advanced/entrypoints-contracts.md index dff0a535a..13395d48d 100644 --- a/gitlab-pages/docs/advanced/entrypoints-contracts.md +++ b/gitlab-pages/docs/advanced/entrypoints-contracts.md @@ -298,10 +298,11 @@ type action = let dest: address = ("KT19wgxcuXG9VH4Af5Tpm1vqEKdaMFpznXT3": address); -let proxy = ((param, s): (action, unit)): (list(operation), unit) => +let proxy = ((param, s): (action, unit)): (list(operation), unit) => { let counter: contract(action) = Operation.get_contract(dest); let op: operation = Operation.transaction(param, 0mutez, counter); ([op], s); +}; ``` diff --git a/src/test/contracts/negative/gitlab_111.religo b/src/test/contracts/negative/gitlab_111.religo new file mode 100644 index 000000000..3103973fc --- /dev/null +++ b/src/test/contracts/negative/gitlab_111.religo @@ -0,0 +1,58 @@ +type fraction = +{ + num : int, + den : nat +}; + +type storage = fraction; +type parameter = unit; + + +let twopow_aux = (base : nat, accu : nat, n : nat) => + if (n > 0n) { + if (n mod 2n == 1n) { + continue((base * base, accu * base, n / 2n)); + } else { + continue((base * base, accu, n / 2n)); + }; + } else { + stop((base, accu, n)); + }; + +let twopow = (n : nat) : nat => { + let (_, x, _) = Loop.fold_while(twopow_aux, (2n, 1n, n)); + x +}; + +let tp = +let exp = (x : fraction) : fraction => { + let r : int = 1649 * x.num; + let s : nat = 1143n * x.den; + let ab = { + num: r / int(s), den: r mod s + }; + + let (i, f) = + if (2n * ab.den <= s) { + (ab.num, {num: ab.den, den: 1649n * x.den}); + } + else { + (ab.num + 1, {num: ab.den - s, den: 1649n * x.den}); + }; + let pow : nat = twopow(abs(i)); + let tp = if (i > 0) {{num:int(pow), den:1n};} else {{num:1, den:pow};}; + let num : int = (f.num * f.num + 6 * f.num * int(f.den) + int(12n * f.den * f.den)) * tp.num; + let den : int = (f.num * f.num - 6 * f.num * int(f.den) + int(12n * f.den * f.den)) * int(tp.den); + if (den < 0) + { + {num:-num, den:abs(den)}; + } else { + {num:num, den:den}; + }; +}; + +let main = (p : parameter, s : storage) => +{ + let r = exp(s); + ([]: list(operation), r) +};