Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Unified Diff: src/parsing/scanner.cc

Issue 2510873005: A decimal integer literal with a leading 0 is now an error in strict mode. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/parsing/scanner.cc
diff --git a/src/parsing/scanner.cc b/src/parsing/scanner.cc
index cfc0410b83cc77cbb78984aba151113d94429633..fd8669a0f9e35ac2606de403c245a97acaa03325 100644
--- a/src/parsing/scanner.cc
+++ b/src/parsing/scanner.cc
@@ -78,10 +78,8 @@ bool Scanner::BookmarkScope::HasBeenApplied() {
Scanner::Scanner(UnicodeCache* unicode_cache)
: unicode_cache_(unicode_cache),
octal_pos_(Location::invalid()),
- decimal_with_leading_zero_pos_(Location::invalid()),
- found_html_comment_(false) {
-}
-
+ octal_message_(MessageTemplate::kNone),
+ found_html_comment_(false) {}
void Scanner::Initialize(Utf16CharacterStream* source) {
source_ = source;
@@ -917,6 +915,7 @@ uc32 Scanner::ScanOctalEscape(uc32 c, int length) {
// occur before the "use strict" directive.
if (c != '0' || i > 0) {
octal_pos_ = Location(source_pos() - i - 1, source_pos() - 1);
+ octal_message_ = MessageTemplate::kStrictOctalEscape;
}
return x;
}
@@ -1130,6 +1129,7 @@ Token::Value Scanner::ScanNumber(bool seen_period) {
if (c0_ < '0' || '7' < c0_) {
// Octal literal finished.
octal_pos_ = Location(start_pos, source_pos());
+ octal_message_ = MessageTemplate::kStrictOctalLiteral;
break;
}
AddLiteralCharAdvance();
@@ -1157,8 +1157,10 @@ Token::Value Scanner::ScanNumber(bool seen_period) {
literal.Complete();
HandleLeadSurrogate();
- if (kind == DECIMAL_WITH_LEADING_ZERO)
- decimal_with_leading_zero_pos_ = Location(start_pos, source_pos());
+ if (kind == DECIMAL_WITH_LEADING_ZERO) {
+ octal_pos_ = Location(start_pos, source_pos());
+ octal_message_ = MessageTemplate::kStrictOctalLiteral;
+ }
return Token::SMI;
}
HandleLeadSurrogate();
@@ -1198,8 +1200,10 @@ Token::Value Scanner::ScanNumber(bool seen_period) {
literal.Complete();
- if (kind == DECIMAL_WITH_LEADING_ZERO)
- decimal_with_leading_zero_pos_ = Location(start_pos, source_pos());
+ if (kind == DECIMAL_WITH_LEADING_ZERO) {
+ octal_pos_ = Location(start_pos, source_pos());
+ octal_message_ = MessageTemplate::kStrictOctalLiteral;
+ }
return Token::NUMBER;
}

Powered by Google App Engine
This is Rietveld 408576698