Skip to content

Commit

Permalink
parser: allow numeric literals as object keys
Browse files Browse the repository at this point in the history
  • Loading branch information
belochub committed Jun 17, 2017
1 parent 1f1d7d0 commit e1df391
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/jsrs_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ MaybeLocal<Value> ParseObject(Isolate* isolate,
bool key_mode = true;
*size = end - begin;
MaybeLocal<String> current_key;
MaybeLocal<Value> current_numeric_key;
MaybeLocal<Value> current_value;
size_t current_length = 0;
auto result = Object::New(isolate);
Expand All @@ -734,10 +735,16 @@ MaybeLocal<Value> ParseObject(Isolate* isolate,
has_ended = true;
break;
}
current_key = ParseKeyInObject(isolate,
begin + i,
end,
&current_length);
if (!isdigit(begin[i])) {
current_key = ParseKeyInObject(isolate, begin + i, end,
&current_length);
} else {
current_numeric_key = ParseNumber(isolate, begin + i, end,
&current_length);
current_key = current_numeric_key.IsEmpty() ? MaybeLocal<String>() :
current_numeric_key.ToLocalChecked()->ToString(
isolate->GetCurrentContext());
}
if (current_key.IsEmpty()) {
return MaybeLocal<Value>();
}
Expand Down

0 comments on commit e1df391

Please sign in to comment.