diff --git a/src/regexp/regexp-parser.cc b/src/regexp/regexp-parser.cc index ef7ae24e273d..8d27289053f2 100644 --- a/src/regexp/regexp-parser.cc +++ b/src/regexp/regexp-parser.cc @@ -2774,6 +2774,14 @@ RegExpTree* RegExpParserImpl::ParseClassUnion( return ReportError(RegExpError::kNegatedCharacterClassWithStrings); } + if (operands->is_empty()) { + // Return empty expression if no operands were added (e.g. [\P{Any}] + // produces an empty range). + DCHECK(ranges->is_empty()); + DCHECK(strings->empty()); + return RegExpClassSetExpression::Empty(zone(), is_negated); + } + return zone()->template New( RegExpClassSetExpression::OperationType::kUnion, is_negated, may_contain_strings, operands); diff --git a/test/mjsunit/regress/regress-crbug-1437346.js b/test/mjsunit/regress/regress-crbug-1437346.js new file mode 100644 index 000000000000..d94789c0e5fd --- /dev/null +++ b/test/mjsunit/regress/regress-crbug-1437346.js @@ -0,0 +1,5 @@ +// Copyright 2023 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +assertFalse(/[\P{Any}]/v.test());