From 6b0d54a21f4cbfbc185b0529fa1cdcb97fe330e0 Mon Sep 17 00:00:00 2001 From: Gabor Greif Date: Mon, 12 Aug 2024 16:00:49 +0200 Subject: [PATCH] handle stacked parenthetials --- src/mo_frontend/parser.mly | 10 +++++----- test/run-drun/ok/par.drun-run.ok | 4 ++++ test/run-drun/par.mo | 21 ++++++++++++++++----- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/mo_frontend/parser.mly b/src/mo_frontend/parser.mly index 4d0b5080628..6413108b818 100644 --- a/src/mo_frontend/parser.mly +++ b/src/mo_frontend/parser.mly @@ -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 } diff --git a/test/run-drun/ok/par.drun-run.ok b/test/run-drun/ok/par.drun-run.ok index a6f776f43c6..3bbc00e091b 100644 --- a/test/run-drun/ok/par.drun-run.ok +++ b/test/run-drun/ok/par.drun-run.ok @@ -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 diff --git a/test/run-drun/par.mo b/test/run-drun/par.mo index f350e3eed92..33b1800159c 100644 --- a/test/run-drun/par.mo +++ b/test/run-drun/par.mo @@ -1,3 +1,6 @@ +import { debugPrint } "mo:⛔"; +import Cycles = "cycles/cycles"; + actor { func foo(next : () -> async ()) : async () { @@ -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 { @@ -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()); @@ -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"