diff --git a/src/desugar.ml b/src/desugar.ml index becb43e73a9..9359915cbe2 100644 --- a/src/desugar.ml +++ b/src/desugar.ml @@ -67,6 +67,7 @@ and exp' at note = function let cc = Value.call_conv_of_typ e1.Source.note.S.note_typ in let inst = List.map (fun t -> t.Source.note) inst in I.CallE (cc, exp e1, inst, exp e2) + | S.BlockE ([{it = S.ExpD e; _}], _) -> exp' e.at e.note e.it | S.BlockE (ds, ot) -> I.BlockE (decs ds, !ot) | S.NotE e -> I.IfE (exp e, falseE, trueE) | S.AndE (e1, e2) -> I.IfE (exp e1, exp e2, falseE) diff --git a/src/type.ml b/src/type.ml index 33bb6a837f4..4726ff5aea9 100644 --- a/src/type.ml +++ b/src/type.ml @@ -427,7 +427,7 @@ let rec rel_typ env rel eq t1 t2 = s1 = s2 && rel_fields env rel eq tfs1 tfs2 | Obj (s, _), Shared when rel != eq -> - s != Object Local + s <> Object Local | Array t1', Array t2' -> rel_typ env rel eq t1' t2' | Array t1', Obj _ when rel != eq -> diff --git a/test/fail/ok/issue103.tc.ok b/test/fail/ok/issue103.tc.ok index 1740e3ce0e3..d0f8ed19484 100644 --- a/test/fail/ok/issue103.tc.ok +++ b/test/fail/ok/issue103.tc.ok @@ -1,4 +1,8 @@ issue103.as:3.29-3.40: type error, shared function has non-shared parameter type () -> Nat +issue103.as:10.29-10.46: type error, shared function has non-shared parameter type + {foo : () -> Nat} issue103.as:17.29-17.40: type error, async type has non-shared parameter type () -> Nat +issue103.as:24.29-24.48: type error, async type has non-shared parameter type + {foo : () -> Nat} diff --git a/test/run-dfinity/chatpp.as b/test/run-dfinity/chatpp.as index 1b386e4a9f3..631b6f41a98 100644 --- a/test/run-dfinity/chatpp.as +++ b/test/run-dfinity/chatpp.as @@ -1,7 +1,7 @@ /* a simple data structure: mutable, singly linked list */ type List = ?{head: T; var tail: List}; -type subscription = { +type subscription = shared { post : shared Text -> async (); /* revokable by Server */ cancel : shared () -> (); }; @@ -51,7 +51,7 @@ actor Server = { nextId += 1; let cs = new { head = c; var tail = clients}; clients := ?cs; - return (new { + return (shared { post = (shared func (message:Text) : async () { if (not (c.revoked)) await broadcast(c.id, message); diff --git a/test/run-dfinity/data-params.as b/test/run-dfinity/data-params.as index bfe970521b8..c47ad52ce98 100644 --- a/test/run-dfinity/data-params.as +++ b/test/run-dfinity/data-params.as @@ -28,7 +28,7 @@ let a = actor { printInt(c); print("\n"); }; - increcord(a : { x : Nat; y : Nat }) : () { + increcord(a : shared { x : Nat; y : Nat }) : () { c += a.x; c += a.y; printInt(c); @@ -60,8 +60,8 @@ a.incnested(7,(8,9)); a.incarray([10,11,12,13]); a.incopt(null); a.incopt(?14); -a.increcord(new {x = 15; y = 16}); -a.increcord(new {x = 17; y = 18; z = 19}); +a.increcord(shared {x = 15; y = 16}); +a.increcord(shared {x = 17; y = 18; z = 19}); a.printCounter(); a.printLabeled("Foo: "); // a.readCounter(func (n : Nat) = { printInt n; print("\n") }); diff --git a/test/run-dfinity/ok/counter-class.wasm.stderr.ok b/test/run-dfinity/ok/counter-class.wasm.stderr.ok index 04999878853..b2fdd988684 100644 --- a/test/run-dfinity/ok/counter-class.wasm.stderr.ok +++ b/test/run-dfinity/ok/counter-class.wasm.stderr.ok @@ -39,7 +39,7 @@ non-closed actor: (ActorE $lambda (VarP $0) () - (CallE ( 1 -> 0) (VarE $0) (BlockE (ExpD (VarE c)) Int)) + (CallE ( 1 -> 0) (VarE $0) (VarE c)) ) (Int -> ()) -> () ) diff --git a/test/run/for.as b/test/run/for.as index dc8d83d7eed..1f62f884f24 100644 --- a/test/run/for.as +++ b/test/run/for.as @@ -10,16 +10,6 @@ async { assert(i == 11); }; -{ - var i = 0; - for (j in await async (range(0, 10))) { - printInt(j); - assert(j == i); - i += 1; - }; - assert(i == 11); -}; - { var i = 0; i := 0; @@ -31,19 +21,4 @@ async { assert(i == 11); }; -{ - var i = 0; - for (j in await async (range(0, 10))) { - printInt(j); - assert(j == i); - await (async (i += 1)); - }; - assert(i == 11); }; - -}; - - - - - diff --git a/test/run/ok/for.run-ir.ok b/test/run/ok/for.run-ir.ok index ac6ac408923..0b36fe95ae6 100644 --- a/test/run/ok/for.run-ir.ok +++ b/test/run/ok/for.run-ir.ok @@ -1 +1 @@ -012345678910012345678910012345678910012345678910 +012345678910012345678910 diff --git a/test/run/ok/for.run-low.ok b/test/run/ok/for.run-low.ok index ac6ac408923..0b36fe95ae6 100644 --- a/test/run/ok/for.run-low.ok +++ b/test/run/ok/for.run-low.ok @@ -1 +1 @@ -012345678910012345678910012345678910012345678910 +012345678910012345678910 diff --git a/test/run/ok/for.run.ok b/test/run/ok/for.run.ok index ac6ac408923..0b36fe95ae6 100644 --- a/test/run/ok/for.run.ok +++ b/test/run/ok/for.run.ok @@ -1 +1 @@ -012345678910012345678910012345678910012345678910 +012345678910012345678910