JavaScript parser: Don't drop the token after an unbraced if
If an `if` haven't had braces, the code used to check itself for an `else` after it, eating the next token if it wasn't actually an `else`. So, drop the check for the else altogether since parseLine() handles `else`s by calling parseIf() anyway. This fixes constructs like: if (foo) bar(); function baz() { // ... } Closes #3568542.
This commit is contained in:
parent
66888d580f
commit
297bca3799
@ -805,36 +805,9 @@ static boolean parseIf (tokenInfo *const token)
|
|||||||
{
|
{
|
||||||
findCmdTerm (token);
|
findCmdTerm (token);
|
||||||
|
|
||||||
/*
|
/* The next token should only be read if this statement had its own
|
||||||
* The IF could be followed by an ELSE statement.
|
* terminator */
|
||||||
* This too could have two formats, a curly braced
|
read_next_token = isType (token, TOKEN_SEMICOLON);
|
||||||
* multiline section, or another single line.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (isType (token, TOKEN_CLOSE_CURLY))
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* This statement did not have a line terminator.
|
|
||||||
*/
|
|
||||||
read_next_token = FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
readToken (token);
|
|
||||||
|
|
||||||
if (isType (token, TOKEN_CLOSE_CURLY))
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* This statement did not have a line terminator.
|
|
||||||
*/
|
|
||||||
read_next_token = FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (isKeyword (token, KEYWORD_else))
|
|
||||||
read_next_token = parseIf (token);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return read_next_token;
|
return read_next_token;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user