Code Monkey home page Code Monkey logo

Comments (3)

LadyCailinBot avatar LadyCailinBot commented on July 19, 2024

Comment by PseudoKnight

I've run into similar bugs in the compiler optimizer. In fact, there's some super strange ones. If you embed an if(a) inside of an if(b){} then it'll convert it to if(a && b){} ... sometimes. This is almost always undesirable so I have to work around it. What's weird is that it depends on what I'm checking in the if(). Some functions will cause it while others won't.

Unfortunately I think we'll have to wait for the compiler rewrite for a fix, unless this is deemed critical enough. I could be wrong.

from commandhelper.

LadyCailinBot avatar LadyCailinBot commented on July 19, 2024

Comment by LadyCailin

I don't think this is an issue anymore. I fixed some of the biggest issues in the current compiler, this being one of them. I did confirm with the optimizer test that it's compiling correctly, which it appears to be (comments mine): http://paste.thezomg.com/10612/61030971/ As you can clearly see (lol) the cancelled message is being sent as the third argument to the ifelse, so I'm going to close this as fixed.

Also, PseudoKnight, FYI, both of these are ALWAYS equivalent:

if(@a){
    if(@b){
        msg('hi')
    }
}

and

if(@a && @b){
    msg('hi')
}

But if and only if there are no other statements other than the if (including an inner else/else if) in the outer if, and as it turns out, doing the one if with an and is faster than two ifs. This is of course a micro-optimization, but that's what compilers are for :)

from commandhelper.

LadyCailinBot avatar LadyCailinBot commented on July 19, 2024

Comment by PseudoKnight

Yes, there were other statements in the outer if() in code where I was encountering that bug. It was a headache to figure out what exactly was causing the logic problem in my code. It was optimizing when it shouldn't have. I have no idea if it's fixed as it was hard to reliably recreate, as I mentioned. I'll start using brace syntax in these situations again and let you know if I encounter it again.

from commandhelper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.