Commit 169f92b5 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

jscript: Fix shift/reduce conflict in IfStatement rule.

The famous "dangling else" problem.
parent 7b9e827a
......@@ -253,6 +253,9 @@ static source_elements_t *source_elements_add_function(source_elements_t*,functi
%type <literal> BooleanLiteral
%type <srcptr> KFunction
%nonassoc LOWER_THAN_ELSE
%nonassoc kELSE
%%
/* ECMA-262 3rd Edition 14 */
......@@ -389,7 +392,7 @@ ExpressionStatement
IfStatement
: kIF '(' Expression ')' Statement kELSE Statement
{ $$ = new_if_statement(ctx, $3, $5, $7); }
| kIF '(' Expression ')' Statement
| kIF '(' Expression ')' Statement %prec LOWER_THAN_ELSE
{ $$ = new_if_statement(ctx, $3, $5, NULL); }
/* ECMA-262 3rd Edition 12.6 */
......
......@@ -773,6 +773,18 @@ try {
ok(false, "deleteTest not throwed exception?");
}catch(ex) {}
if (false)
if (true)
ok(false, "if evaluated");
else
ok(false, "else should be associated with nearest if statement");
if (true)
if (false)
ok(false, "if evaluated");
else
ok(true, "else should be associated with nearest if statement");
ok(isNaN(0.5) === false, "isNaN(0.5) !== false");
ok(isNaN() === true, "isNaN() !== true");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment