Comments (3)
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.
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.
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)
- Core exception when using stop_named_sound
- Provide schema for Persistence Network
- Provide `nocatch` keyword HOT 4
- ba_get_bytes() (always?) returns a zero-size byte_array
- [Feature request] has_inventory
- pfacing resets player velocity to 0 HOT 2
- entity_spec and set_entity_spec do not have support for InLove
- Possible EOFException in SerializedPersistence during recompile HOT 2
- add support for tools/items in break_block
- [BUG] set_pinv(pinv()) clears BlockStateTag values
- item_swap event docs don't match actual behavior HOT 1
- set_pinv(pinv()) clears EntityTag values HOT 3
- False BlockState default values (also enforced after set_pinv(pinv()) ) HOT 1
- Using switch_ic the break() function gives a compile error HOT 1
- [Feature request] InventoryPickupItemEvent and InventoryMoveItemEvent
- Errors with persistence can leak DB password in error messages
- Using unexisting functions in `foreach(... in ...) {}` syntax results in unexpected additional compile errors
- [Feature request] colorize() to support hex colors HOT 11
- "@var was already defined" runtime error on typed foreach loop variable HOT 1
- Improve handling of offline players during events HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from commandhelper.