Commit 1a89ea70 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Improved error handling in numeric literal parser.

parent 4d9ea4b5
...@@ -454,6 +454,11 @@ static int parse_double_literal(parser_ctx_t *ctx, LONG int_part, literal_t **li ...@@ -454,6 +454,11 @@ static int parse_double_literal(parser_ctx_t *ctx, LONG int_part, literal_t **li
else exp += e; else exp += e;
} }
if(is_identifier_char(*ctx->ptr)) {
WARN("wrong char after zero\n");
return lex_error(ctx, JS_E_MISSING_SEMICOLON);
}
*literal = new_double_literal(ctx, exp>=0 ? d*pow(10, exp) : d/pow(10, -exp)); *literal = new_double_literal(ctx, exp>=0 ? d*pow(10, exp) : d/pow(10, -exp));
return tNumericLiteral; return tNumericLiteral;
} }
...@@ -477,7 +482,7 @@ static int parse_numeric_literal(parser_ctx_t *ctx, literal_t **literal) ...@@ -477,7 +482,7 @@ static int parse_numeric_literal(parser_ctx_t *ctx, literal_t **literal)
if(ctx->ptr < ctx->end && is_identifier_char(*ctx->ptr)) { if(ctx->ptr < ctx->end && is_identifier_char(*ctx->ptr)) {
WARN("unexpected identifier char\n"); WARN("unexpected identifier char\n");
return lex_error(ctx, E_FAIL); return lex_error(ctx, JS_E_MISSING_SEMICOLON);
} }
*literal = new_double_literal(ctx, l); *literal = new_double_literal(ctx, l);
...@@ -512,9 +517,8 @@ static int parse_numeric_literal(parser_ctx_t *ctx, literal_t **literal) ...@@ -512,9 +517,8 @@ static int parse_numeric_literal(parser_ctx_t *ctx, literal_t **literal)
if(is_identifier_char(*ctx->ptr)) { if(is_identifier_char(*ctx->ptr)) {
WARN("wrong char after zero\n"); WARN("wrong char after zero\n");
return lex_error(ctx, E_FAIL); return lex_error(ctx, JS_E_MISSING_SEMICOLON);
} }
} }
return parse_double_literal(ctx, l, literal); return parse_double_literal(ctx, l, literal);
......
...@@ -2357,6 +2357,13 @@ testSyntaxError("ok(false, 'unexpected execution'); while(true) continue some_la ...@@ -2357,6 +2357,13 @@ testSyntaxError("ok(false, 'unexpected execution'); while(true) continue some_la
testSyntaxError("ok(false, 'unexpected execution'); some_label: { while(true) continue some_label; }", "E_INVALID_CONTINUE"); testSyntaxError("ok(false, 'unexpected execution'); some_label: { while(true) continue some_label; }", "E_INVALID_CONTINUE");
testSyntaxError("ok(false, 'unexpected execution'); some_label: { some_label: while(true); }", "E_LABEL_REDEFINED"); testSyntaxError("ok(false, 'unexpected execution'); some_label: { some_label: while(true); }", "E_LABEL_REDEFINED");
testSyntaxError("return;", "E_MISPLACED_RETURN"); testSyntaxError("return;", "E_MISPLACED_RETURN");
testSyntaxError("001.5;", "E_SEMICOLON");
testSyntaxError("001.5", "E_SEMICOLON");
testSyntaxError("0a", "E_SEMICOLON");
testSyntaxError("01a", "E_SEMICOLON");
testSyntaxError("0x1r", "E_SEMICOLON");
testSyntaxError("1a", "E_SEMICOLON");
testSyntaxError("1_", "E_SEMICOLON");
// ReferenceError tests // ReferenceError tests
testException(function() {test = function() {}}, "E_ILLEGAL_ASSIGN"); testException(function() {test = function() {}}, "E_ILLEGAL_ASSIGN");
......
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