From 49fdbb784d97c7e2b53ed6f6672f089789d18757 Mon Sep 17 00:00:00 2001 From: Johan Nordlander Date: Wed, 25 Aug 2021 17:50:55 +0200 Subject: [PATCH 1/3] Relaxed declaration groups. Stopped declaration groups from breaking in the middle of actor/class/protocol sequences. This captures forward dependencies that only exist in terms of attribute selections more naturally. --- compiler/Acton/Names.hs | 9 +++++---- test/regression/105-type-inference-order.act | 7 ++++--- test/regression/Makefile | 1 - 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/compiler/Acton/Names.hs b/compiler/Acton/Names.hs index 9abd41959..8e172183d 100644 --- a/compiler/Acton/Names.hs +++ b/compiler/Acton/Names.hs @@ -54,10 +54,11 @@ declnames [] = [] splitDeclGroup [] = [] splitDeclGroup (d:ds) = split (free d) [d] ds where split vs ds0 [] = [reverse ds0] - split vs ds0 (d:ds) + split vs ds0 (d@Def{}:ds) | any (`elem` ws) vs = split (free d++vs) (d:ds0) ds | otherwise = reverse ds0 : split (free d) [d] ds where ws = declnames (d:ds) + split vs ds0 (d:ds) = split (free d++vs) (d:ds0) ds -- Control flow -------------------- @@ -299,17 +300,17 @@ instance Vars WithItem where free (WithItem e p) = free e ++ free p bound (WithItem e p) = bound p - + instance Vars PosArg where free (PosArg e p) = free e ++ free p free (PosStar e) = free e free PosNil = [] - + instance Vars KwdArg where free (KwdArg n e k) = free e ++ free k free (KwdStar e) = free e free KwdNil = [] - + instance Vars OpArg where free (OpArg o e) = free e diff --git a/test/regression/105-type-inference-order.act b/test/regression/105-type-inference-order.act index 99806fb4b..74deb4a5d 100644 --- a/test/regression/105-type-inference-order.act +++ b/test/regression/105-type-inference-order.act @@ -1,10 +1,11 @@ actor Bar(f): - f.func(3) + f.func('x') actor Foo(): def func(a): print(a) actor main(env): - var f = Foo() - var b = Bar(f) + f = Foo() + b = Bar(f) + await async env.exit(0) diff --git a/test/regression/Makefile b/test/regression/Makefile index 68aac3393..748f45d5a 100644 --- a/test/regression/Makefile +++ b/test/regression/Makefile @@ -14,7 +14,6 @@ FAILING_COMPILATION= \ 11-int-float \ 12-for-actor \ 20-for-break \ - 105-type-inference-order \ if-return \ quotes-in-triquotes \ rtail \ From 461b820b7f80b3467475f118991e713d6249abd9 Mon Sep 17 00:00:00 2001 From: Johan Nordlander Date: Wed, 25 Aug 2021 19:43:18 +0200 Subject: [PATCH 2/3] Made the deactorizer use correctly sealed environments even within recursive groups. --- compiler/Acton/Deactorizer.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/Acton/Deactorizer.hs b/compiler/Acton/Deactorizer.hs index 876962c88..b19ece04f 100644 --- a/compiler/Acton/Deactorizer.hs +++ b/compiler/Acton/Deactorizer.hs @@ -154,7 +154,7 @@ deactSuite env [] = return [] deactSuite env (s : ss) = do s' <- deact (setSampled ns env) s ss' <- deactSuite env1 ss return (samples ++ s' : ss') - where env1 = extend (envOf s) env + where env1 = extend (map sealActors $ envOf s) env ns = nub $ stvars env `intersect` lamfree s samples = [ sAssign (pVar n $ typeOf env (eVar n)) (eDot (eVar selfKW) n) | n <- ns ] @@ -187,7 +187,7 @@ instance Deact Stmt where where t2 = typeOf env e2 t = tFun fxAction posNil kwdNil t2 deact env (Decl l ds) = Decl l <$> deact env1 ds - where env1 = extend (envOf ds) env + where env1 = extend (map sealActors $ envOf ds) env deact env (Signature l ns t d) = return $ Signature l ns t d deact env s = error ("deact unexpected stmt: " ++ prstr s) From bea23da1e9e3e3c272b3fdcccd88c5ecc77964d3 Mon Sep 17 00:00:00 2001 From: Johan Nordlander Date: Wed, 25 Aug 2021 19:44:14 +0200 Subject: [PATCH 3/3] Test update, more successes. --- test/regression/Makefile | 6 ++---- test/regression/rtail.act | 3 --- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/test/regression/Makefile b/test/regression/Makefile index 748f45d5a..565df8315 100644 --- a/test/regression/Makefile +++ b/test/regression/Makefile @@ -16,7 +16,6 @@ FAILING_COMPILATION= \ 20-for-break \ if-return \ quotes-in-triquotes \ - rtail \ triquotes-across-lines FAILING_RUNNING= \ 125-async-actor-method-call \ @@ -51,9 +50,8 @@ $(FAILING_RUNNING): 13-print-actor-method: $(ACTONC) $@.act --root main - @echo "We really should see 2 'pong' messages, but will see 1 due to bug #13" - @echo "Since this is a negative test, we check for 1, this can later be changed to 2 when working" + @echo "Now we really see 2 'pong' messages" ./$@ - ./$@ | grep -c pong | grep 1 + ./$@ | grep -c pong | grep 2 .PHONY: test test-examples $(TESTS) diff --git a/test/regression/rtail.act b/test/regression/rtail.act index ae88cea0f..88074b7aa 100644 --- a/test/regression/rtail.act +++ b/test/regression/rtail.act @@ -1,8 +1,5 @@ def read(filename): -# Simply uncommenting this comment makes the program work -# print("fake reading") a = "blargh" - return a actor main(env):