Menu

#5 else without if

closed
None
5
2003-11-12
2003-11-06
No

if (x==y)
somemethod();
else
{
somemethod();
somemethod();
}

When you have something like the above in anything
janino compiles, it complains about an else without if.

Discussion

  • Arno Unkrig

    Arno Unkrig - 2003-11-12

    Logged In: YES
    user_id=865893

    That's a good one... Janino forgot to parse the semicolon at
    the end of the expression statement. ("somemethod();" is an
    expression statement.) Thus, it parses the semicolon as an
    extra "empty statement". The only difference that this makes
    is that we now have TWO statements. Your statement

    if (x==y)
    somemethod();
    else {
    somemethod();
    somemethod();
    }

    is thus parsed as

    if (x==y)
    somemethod()
    ;
    else // <= "else" without "if".

    Will release the fix tonight as version 1.0.3.

     
  • Arno Unkrig

    Arno Unkrig - 2003-11-12
    • assigned_to: nobody --> mecki
    • status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB