Skip to content

Commit

Permalink
Merge pull request #142 from actonlang/109-order-fix
Browse files Browse the repository at this point in the history
109 order fix
  • Loading branch information
nordlander authored Aug 25, 2021
2 parents 1866f46 + bea23da commit 7a7fdde
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
4 changes: 2 additions & 2 deletions compiler/Acton/Deactorizer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]

Expand Down Expand Up @@ -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)

Expand Down
9 changes: 5 additions & 4 deletions compiler/Acton/Names.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 --------------------
Expand Down Expand Up @@ -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

Expand Down
7 changes: 4 additions & 3 deletions test/regression/105-type-inference-order.act
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 2 additions & 5 deletions test/regression/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ FAILING_COMPILATION= \
11-int-float \
12-for-actor \
20-for-break \
105-type-inference-order \
if-return \
quotes-in-triquotes \
rtail \
triquotes-across-lines
FAILING_RUNNING= \
125-async-actor-method-call \
Expand Down Expand Up @@ -52,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)
3 changes: 0 additions & 3 deletions test/regression/rtail.act
Original file line number Diff line number Diff line change
@@ -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):
Expand Down

0 comments on commit 7a7fdde

Please sign in to comment.