Welcome Guest Search | Active Topics | Log In | Register

Bug in if-else when else is incorrectly given a condition
#1 Posted : Saturday, June 25, 2016 3:47:12 AM(UTC)
Rank: Member

Groups: Registered
Joined: 12/5/2010(UTC)
Posts: 20
Location: Roslindale, MA

Thanks: 9 times
Was thanked: 2 time(s) in 2 post(s)
This isn't the actual code, but a simplified version of something I accidentally did:


local var = true;
if (var)
    print ("Output when true\n");
else (!var)
    print ("Output when false\n");

I meant to have an else if condition. Squirrel compiles and executes it no problem, and prints both output conditions. C++ refuses to compile this kind of mistake. I know this was my own fault, but I think Squirrel should catch this early.

I know I'm a little behind in versions, so apologies if this is a known bug.

#2 Posted : Saturday, June 25, 2016 8:47:33 PM(UTC)
Rank: Advanced Member

Groups: Registered, Administrators
Joined: 6/11/2005(UTC)
Posts: 1,062

Thanks: 0 times
Was thanked: 80 time(s) in 62 post(s)
Technically that is valid in squirrel syntax

it parse like this:

else [expression] [optional semicolon]

if you place a semicolon that is valid c++

Follow me on Twitter @squirrellang
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.122 seconds.