encore
encore copied to clipboard
Error generating c-code when mutually calling stream functions in the same active class
In the same class, the c-code is generated incorrect when calling one stream function inside another stream function. One argument is missing/ when generating c-code.
For instance:
class Foo {
stream foo1() : int
yield 1
stream foo2() : int
let foo3 = this.foo1()
in yield 2
}
class Main
def main() : void
()
The error:
test_src/Foo.encore.c:67:66: error: too few arguments to function call, expected 3, have 2
int64_t _sync_method_call_0 = _enc__method_Foo_foo1(_ctx, _this);
~~~~~~~~~~~~~~~~~~~~~ ^
test_src/Foo.encore.c:52:1: note: '_enc__method_Foo_foo1' declared here
void _enc__method_Foo_foo1(pony_ctx_t* _ctx, _enc__active_Foo_t* _this, stream_t* _stream)
^
1 error generated.
*** Compilation failed with exit code 1 ***
Calling a streaming method on yourself is semantically interesting (i.e. "what does it mean?"). If foo2
was to call get foo3
, the actor would deadlock, so you can't read from your own stream. I would guess that the only thing you can do with foo3
is return it (after which the actor itself can start populating the stream) or pass it to another actor. What's the intended use case?
In any case, the error stems from the fact that all calls on this
are considered synchronous. Look at the MethodCall
cases in Expr.hs
and Typechecker.hs
. A temporary workaround might be to bind this
to another variable and call the streaming method on that:
stream foo2() : int {
let that = this;
let foo3 = that.foo1();
yield 2;
}
Not the get this.foo3
case. My intention is to pass this.foo3()
, the expected result of stream foo2() : Stream int
is Stream (Stream int)
.
We probably can fix it by placing foo2()
and foo1()
in 2 different active classes
, but I don't think that's a good way.
Ideally, one could continue the stream produced in foo2
with the one produced by foo1
.
This needs language level support, though.
@PhucVH888 @EliasC @kikofernandez
This is blocking me ticking off the October 16 sprint (!). Can this be removed or moved elsewhere so I can tick it off?
I think that things that have not been achieved in the milestone should be moved to an "Incomplete milestone" or similar, where we can start piling up things that we did not manage to finish on time and should be moved / reconsider for next milestone
Thanks Kiko. Doing that now!
If we agree with my approach, we can have the monthly review on what has been and what has NOT been achieved. We could discuss the reasons for not finishing on time. It could be that we underestimated the issue, that the assigned person doesn't have time at the moment or that the assignee (person in charge) needs a bit of help :)