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

Int gets coerced to Time somehow? #87

Open
TiZ-HugLife opened this issue Oct 12, 2015 · 3 comments
Open

Int gets coerced to Time somehow? #87

TiZ-HugLife opened this issue Oct 12, 2015 · 3 comments

Comments

@TiZ-HugLife
Copy link
Contributor

I'm still trucking along in learning Haxe by doing /r/dailyprogrammer challenges. One of the minis for the week has me calculate the number of "ramp numbers" less than a given number. This program should solve it:

using Thx;
class RampNums {
    static function main () {
        var rampNums = 0, arg = Sys.args()[0].ifEmpty("100");
        for (i in 1 ... (arg.canParse() ? arg.toInt() : 100)) 
            if (i.toString() == i.toString().toArray().order.fn(
             _0.toInt() - _1.toInt()).join("")) rampNums++;
        Sys.println(rampNums.toString());
    }
}

However, when I run the generated bin through the cpp build, I get a time: 1969-12-31 19:00:00 And when I build with neko and run that, I get a crash...

Called from ? line 1
Called from RampNums.hx line 6
Called from RampNums.hx line 6
Called from thx/Iterators.hx line 147
Called from /usr/lib/haxe/std/neko/_std/Array.hx line 344
Called from a C function
Called from RampNums.hx line 7
Uncaught exception - Invalid operation (-)

Do you have any ideas in regards to this weirdness?

@fponticelli
Copy link
Owner

Can you try to reduce that code to a minimal sample? It is really hard to pin point what is going wrong there.

@mlms13
Copy link
Collaborator

mlms13 commented Nov 3, 2015

Seems like this is enough to reproduce it: http://try.thx-lib.org/#Cd0F4

If you remove the .toString() in the trace(), it outputs the correct number.

@fponticelli
Copy link
Owner

Thanks, it is a precedence issue. Will fix it.

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