Skip to content

Commit

Permalink
handle stacked parenthetials
Browse files Browse the repository at this point in the history
  • Loading branch information
ggreif committed Aug 12, 2024
1 parent b3ea1c2 commit 6b0d54a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/mo_frontend/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,11 @@ exp_un(B) :
{ DebugE(e) @? at $sloc }
| LPAR base=exp_post(ob)? WITH fs=seplist(exp_field, semicolon) RPAR e=exp_nest (* parentheticals to qualify message sends *)
{ match e.it with
| CallE (None, f, is, args) ->
{ e with it = CallE (Some (ObjE(Option.to_list base, fs) @? e.at), f, is, args) }
| AsyncE (None, Type.Fut, binds, exp) ->
{ e with it = AsyncE (Some (ObjE(Option.to_list base, fs) @? e.at), Type.Fut, binds, exp) }
| _ -> { e with it = ObjE(Option.to_list base, fs) } (* FIXME: meh *)
| CallE (base0_opt, f, is, args) ->
{ e with it = CallE (Some (ObjE (Option.(to_list base0_opt @ to_list base), fs) @? e.at), f, is, args) }
| AsyncE (base0_opt, Type.Fut, binds, exp) ->
{ e with it = AsyncE (Some (ObjE (Option.(to_list base0_opt @ to_list base), fs) @? e.at), Type.Fut, binds, exp) }
| _ -> e (* FIXME: meh, can we emit a warning? *)
}
| IF b=exp_nullary(ob) e1=exp_nest %prec IF_NO_ELSE
{ IfE(b, e1, TupE([]) @? at $sloc) @? at $sloc }
Expand Down
4 changes: 4 additions & 0 deletions test/run-drun/ok/par.drun-run.ok
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101
ingress Completed: Reply: 0x4449444c0000
debug.print: test()
ingress Completed: Reply: 0x4449444c0000
debug.print: test2()
ingress Completed: Reply: 0x4449444c0000
21 changes: 16 additions & 5 deletions test/run-drun/par.mo
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { debugPrint } "mo:⛔";
import Cycles = "cycles/cycles";

actor {

func foo(next : () -> async ()) : async () {
Expand All @@ -11,7 +14,8 @@ actor {
public func oneshot() {
};

public func test(): async () {
public func test() : async () {
debugPrint "test()";
let message = "Hi!";

func closA() : async Nat {
Expand All @@ -30,7 +34,6 @@ actor {
message.size() + 1
};
*/
assert 42 == 42;
assert 3 == (await (with cycles = 101) closA());
assert 3 == (await (with cycles = 102) closB());

Expand All @@ -40,9 +43,17 @@ actor {
bar(func() : async () = async { assert message == "Hi!" });
};


public func test2() : async () {
await (with cycles = 1042) async { }

debugPrint "test2()";
await (with cycles = 1042) async { assert Cycles.available() == 0/*FIXME: WHY?*/ };
await (with cycles = 3042) (with cycles = 4042) async { assert Cycles.available() == 0/*FIXME: WHY?*/ };
}
}

// testing
//SKIP run
//SKIP run-ir
//SKIP run-low

//CALL ingress test "DIDL\x00\x00"
//CALL ingress test2 "DIDL\x00\x00"

0 comments on commit 6b0d54a

Please sign in to comment.