Skip to content

Commit a467125

Browse files
bcoetargos
authored andcommitted
deps: V8: cherry-pick dfcdf7837e23
Original commit message: [coverage] fix greedy nullish coalescing The SourceRangeScope helper was consuming too many characters, instead explicitly create SourceRange, based on scanner position. Bug: v8:11231 Change-Id: I852d211227abacf867e8f1ab3e3ab06dbdba2a9b Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2576006 Reviewed-by: Toon Verwaest <verwaest@chromium.org> Commit-Queue: Toon Verwaest <verwaest@chromium.org> Cr-Commit-Position: refs/heads/master@{#71765} Refs: v8/v8@dfcdf78 PR-URL: #36573 Fixes: #36619 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
1 parent 7efa020 commit a467125

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.65',
39+
'v8_embedder_string': '-node.66',
4040

4141
##### V8 defaults for Node.js #####
4242

deps/v8/src/parsing/parser-base.h

+9-6
Original file line numberDiff line numberDiff line change
@@ -2973,12 +2973,15 @@ ParserBase<Impl>::ParseCoalesceExpression(ExpressionT expression) {
29732973
bool first_nullish = true;
29742974
while (peek() == Token::NULLISH) {
29752975
SourceRange right_range;
2976-
SourceRangeScope right_range_scope(scanner(), &right_range);
2977-
Consume(Token::NULLISH);
2978-
int pos = peek_position();
2979-
2980-
// Parse BitwiseOR or higher.
2981-
ExpressionT y = ParseBinaryExpression(6);
2976+
int pos;
2977+
ExpressionT y;
2978+
{
2979+
SourceRangeScope right_range_scope(scanner(), &right_range);
2980+
Consume(Token::NULLISH);
2981+
pos = peek_position();
2982+
// Parse BitwiseOR or higher.
2983+
y = ParseBinaryExpression(6);
2984+
}
29822985
if (first_nullish) {
29832986
expression =
29842987
factory()->NewBinaryOperation(Token::NULLISH, expression, y, pos);

deps/v8/test/mjsunit/code-coverage-block.js

+18
Original file line numberDiff line numberDiff line change
@@ -1177,4 +1177,22 @@ a(true); // 0500
11771177
{"start":0,"end":401,"count":2},
11781178
{"start":154,"end":254,"count":0}]);
11791179

1180+
TestCoverage(
1181+
"https://crbug.com/v8/11231 - nullish coalescing",
1182+
`
1183+
const a = true // 0000
1184+
const b = false // 0050
1185+
const c = undefined // 0100
1186+
const d = a ?? 99 // 0150
1187+
const e = 33 // 0200
1188+
const f = b ?? (c ?? 99) // 0250
1189+
const g = 33 // 0300
1190+
const h = c ?? (c ?? 'hello') // 0350
1191+
const i = c ?? b ?? 'hello' // 0400
1192+
`,
1193+
[{"start":0,"end":449,"count":1},
1194+
{"start":162,"end":167,"count":0},
1195+
{"start":262,"end":274,"count":0},
1196+
{"start":417,"end":427,"count":0}]);
1197+
11801198
%DebugToggleBlockCoverage(false);

0 commit comments

Comments
 (0)