Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with interface #15

Open
lerzeel opened this issue Apr 12, 2017 · 4 comments
Open

Issue with interface #15

lerzeel opened this issue Apr 12, 2017 · 4 comments
Assignees

Comments

@lerzeel
Copy link

lerzeel commented Apr 12, 2017

Is it possible to use @await and @async on interfaces? The documentation says interfaces are supported but when I try to compile the following interface I get an error message:

@await interface RandomItemInput2
{
    @async function readPart(): String;
}

The error message is:

D:\haxe\haxe-3.3.0-rc2\lib\tink_await/0,1,7/src/tink/await/AsyncField.hx:34: characters 16-24 : Invalid field access : pos
D:\haxe\haxe-3.3.0-rc2\lib\tink_await/0,1,7/src/tink/await/Await.hx:63: characters 18-35 : Called from
D:\haxe\haxe-3.3.0-rc2\lib\tink_await/0,1,7/src/tink/await/Await.hx:80: characters 35-82 : Called from
D:\haxe\haxe-3.3.0-rc2\lib\tink_await/0,1,7/src/tink/await/Await.hx:47: characters 3-24 : Called from
D:\haxe\haxe-3.3.0-rc2\lib\tink_await/0,1,7/src/tink/await/Await.hx:37: characters 5-15 : Called from
D:\haxe\haxe-3.3.0-rc2\lib\tink_syntaxhub/0,3,6/src/tink/SyntaxHub.hx:43: characters 22-37 : Called from
?:1: characters 2-7 : Called from
Aborted

A quick look at the source code reveals that the members of the interface are being processed. But when the "readPart" function is processed the func.expr value is null. This causes the "expr.pos.makeBlankType()" expression to fail.

Any idea what is causing this problem?

@kevinresol
Copy link
Member

kevinresol commented Apr 12, 2017

I think a quick fix is to not put the meta in the interface, but in the implementation.

So make your interface like this:

interface RandomItemInput2
{
    function readPart():Surprise<String, Dynamic>;
}

and implementation:

@await class Input implements RandomItemInput2
{
    @async public function readPart():String { /* ... */ }

}

But it still worth a look about the bug itself, or maybe we should just amend the readme.

@lerzeel
Copy link
Author

lerzeel commented Apr 12, 2017

Great tip! This seems to solve the problem.

In case someone is trying to find the right import, here it is:
import tink.core.Future.Surprise;

@lerzeel lerzeel closed this as completed Apr 12, 2017
@kevinresol
Copy link
Member

kevinresol commented Apr 12, 2017

using tink.CoreApi; is the recommended way to import everything from tink_core 😄

@kevinresol
Copy link
Member

btw let's keep this open until we fix the readme or something

@kevinresol kevinresol reopened this Apr 12, 2017
@kevinresol kevinresol assigned kevinresol and benmerckx and unassigned kevinresol May 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants