Implement loading namespaces with the using keyword #829

Merged
ghallak merged 23 commits from ghallak/233 into master 2021-09-07 23:45:28 +09:00
4 changed files with 31 additions and 3 deletions
Showing only changes of commit 2d916733d8 - Show all commits

View File

@ -798,6 +798,14 @@ failing_contracts() ->
[<<?Pos(2,3) [<<?Pos(2,3)
"Cannot use undefined namespace MyUndefinedNamespace">> "Cannot use undefined namespace MyUndefinedNamespace">>
]) ])
, ?TYPE_ERROR(using_namespace_undefined_parts,
[<<?Pos(5,3)
"The namespace Nsp does not define the following names: a">>
])
, ?TYPE_ERROR(using_namespace_hidden_parts,
[<<?Pos(8,23)
"Unbound variable g at line 8, column 23">>
])
]. ].
-define(Path(File), "code_errors/" ??File). -define(Path(File), "code_errors/" ??File).

View File

@ -1,15 +1,20 @@
include "Option.aes" include "Option.aes"
include "Pair.aes" include "Pair.aes"
include "String.aes" include "String.aes"
include "Triple.aes"
using Pair using Pair
using Triple hiding [fst, snd]
namespace Nsp = namespace Nsp =
using Option using Option
function h() = function h() =
let op = Some(2) let op = Some((2, 3, 4))
is_some(op) if (is_some(op))
thd(force(op)) == 4
else
false
contract Cntr = contract Cntr =
using Nsp using Nsp
@ -24,7 +29,7 @@ contract Cntr =
snd(p) snd(p)
function g() = function g() =
using String using String for [concat]
let s1 = "abc" let s1 = "abc"
let s2 = "def" let s2 = "def"

View File

@ -0,0 +1,8 @@
namespace Nsp =
function f() = 1
function g() = 2
contract Cntr =
using Nsp for [f]
entrypoint init() = g()

View File

@ -0,0 +1,7 @@
namespace Nsp =
function f() = 1
contract Cntr =
using Nsp for [a]
entrypoint init() = f()