Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

In Flash9, null can't be used as basic type Int + others in flash. #1

Closed
deltaluca opened this Issue · 31 comments

3 participants

@deltaluca

1) InputStream.hx : 120 (null can't be used as basic type Int)
2) Parser.hx : 476 (runtime error, cannot convert 1 to Function).
Also happens (but without a proper stack trace) when using lazyF()

@deltaluca

1) All that needs changing infact to get it to compile so far (Though i'm struggling at present to put together my parser based on the test/ dir so might be more) was to change it from return null; to return 0; Don't see any reason why we can't do that given it's 'abstract' method anyways.

@deltaluca

2) Changing lazy and lazyF so that var value in the tink AST.build macro call is typed Dynamic solved the runtime type error; but did leave my parser in an infinite loop somewhere inside of parsex (producing a back and forth stack overflow with calls to LazyMacro.lazy); removing all lazyF() from my parsers resolved that so far....

@0b1kn00b
Collaborator

Could you post a gist as to how to reproduce the bug? It is most likely fixed, I will test and push the updates.

@deltaluca

I seem to be getting different error using github version; the two i've mentioned don't even get reached; I just get 'Base Failure' form parsex :P

My parser is at: https://github.com/deltaluca/nape/blob/parsex-symbolic/symbolic/src/symbolic/Parser.hx

@deltaluca

Okay; taking the test() function at bottom of parser; changing the parser being tested to 'valueP()' produces the stack overflow with:

An ActionScript error has occurred:
Error: Error #1023: Stack overflow occurred.
    at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-334()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:480]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-311()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:384]
    at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-334()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:480]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-311()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:384]
    at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-334()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:480]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-311()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:384]
    at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-334()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:480]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-311()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:384]
    at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-334()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:480]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-311()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:384]
    at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-334()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:480]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-311()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:384]
    at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-334()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:480]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-311()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:384]
    at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-334()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:480]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-311()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:384]
    at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-334()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:480]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-311()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:384]
    at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
    at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
    at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
@deltaluca

Trying to use ParserM I also get a complaint from ParseMonad.hx that dO expects only one argument, swapping it to use _dO instead which seems to the the one it should be calling produces compile time error:

/home/luca/.haxenekoflash/haxelib/tink_macros/0,2,3/tink/macro/tools/AST.hx:111: characters 16-33 : +
<builtin>:1: character 0 : Called from
/home/luca/.haxenekoflash/haxelib/tink_macros/0,2,3/tink/macro/tools/AST.hx:101: lines 101-245 : Called from
/home/luca/.haxenekoflash/haxelib/tink_macros/0,2,3/tink/macro/tools/AST.hx:23: characters 10-26 : Called from
/home/luca/Projects/Parsex/src/com/mindrocks/macros/LazyMacro.hx:32: lines 32-41 : Called from
/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:374: characters 11-117 : Called from
/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:435: characters 4-30 : Called from
Aborted

:P

@sledorze
Owner

Ok I have no time right now to look at it but I think this is tight to the lazy implementation which is optimized for JS with a hack.

tink.macro.tools.AST.build({
var value = null;
function () {
if (value == null) {

value = untyped 1; // not null to prevent live lock if it forms a cycle.
value = $exp;
}
return value;
};

});

should be replaced by using another var 'computationRequested'

tink.macro.tools.AST.build({
var value = null;
var computationRequested = false;
function () {
if (!computationRequested) {

computationRequested = true;
value = $exp;
}
return value;
};

});

Can you test it?

@sledorze
Owner

the problem above is in the file LazyMacro.hx

@deltaluca

That is certainly a nicer solutino than just making value Dynamic in the build expression :P

But it doesn't change anything else, what on earth is that live-lock even about?

@deltaluca

unless you mean that the stack overflow is meant to be caused by lazyF/lazy, in which case either using Dynamic or computatinRequested it still happens

@sledorze
Owner

Ok, so maybe I've not understood the issue then..
As I'm not able to test it now here, I can't help much ATM.

@sledorze
Owner
@deltaluca

I don't know how to.. execute JS :P

But i compiled to neko, and it all seems to work fine, including no longer having the weird errors from tink when using ParserM.

sigh :P

flash is unfortunately the main target i'm interested i

@sledorze
Owner
@deltaluca

Even the magopP parser which i can never get to work at all on flash is working fine on neko.

@sledorze
Owner
@deltaluca

I'll get one in a short bit.

@deltaluca

Here's a way of producing the tink bug; it actually occurs not only in flash, but neko also:

https://gist.github.com/2225595

@deltaluca

And the stack overflow bug:

https://gist.github.com/2225783

I also had problems, both in neko and flash to do with getting errors like 'value is not a function()' which I could only resolve by adding lazyF(); i don't know if that's a bug or expected in some cases.

@0b1kn00b
Collaborator
@sledorze
Owner

Fixed on Git, published on haxelib - can you confim it works?

@deltaluca

@sledorze, those are the changes I made locally yeh.

@0b1kn00b, when will that be?

@0b1kn00b
Collaborator
@deltaluca

Okay the tink bug test case works fine for flash now.

the stack overflow one still happens in flash though; your tink + stephanes parsex

@sledorze
Owner
@deltaluca

Using official libs versions, then it's the two gists i posted earlier:

https://gist.github.com/2225595 <-- fixed in github tink
https://gist.github.com/2225783 <-- still broke

@deltaluca

I managed to implement my parser without triggering the remaining bug.

I havn't actually used either lazyF or commit at all... Guessing that means I will have some issues with error checking (not tested with dirty input) and maybe performance?

Am I right in guessing that to memoize the parser, I only need to use memo() on the final parser?

@sledorze
Owner

in fact the problem comes with the way macros work; and the fact that you were doing two lazyF (the combinators are lazy by default).
This is too bad, but I can't find a good idea to fix it easily.. (I would have loved to have Lazy values in the AST).

lazy and commit are not for performance;
lazy is to break cycles in computations whereas commit is to say that a parser may no more backtrack.

memo is just a combinator; it applies on the parser you're applying it on - you may play with left recursive grammars to get an idea of it.

@sledorze
Owner

can't/won't fix the remaining issue (the others have been fixed, thanks)

@sledorze sledorze closed this
@deltaluca

I'm already using my own combinator from parsec chainl1 for left recursive grammars actually :)

@sledorze
Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.