YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Bug in if-else when else is incorrectly given a condition
Mephisto
#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:

Code:

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.

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

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

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

it parse like this:

if
[block]
else [expression] [optional semicolon]
[block]

if you place a semicolon that is valid c++

ciao
Alberto
Follow me on Twitter @squirrellang
Users browsing this topic
Guest (2)
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.138 seconds.