Skip to content

Commit d2377a4

Browse files
Don't break ternary with decimal numbers
1 parent f833213 commit d2377a4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/Parser/Scan.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,6 +1783,11 @@ tokens Scanner<EncodingPolicy>::ScanCore(bool identifyKwds)
17831783
}
17841784
else if (m_scriptContext->GetConfig()->IsESOptionalChainingEnabled() && this->PeekFirst(p, last) == '.')
17851785
{
1786+
// `a?.3:0` is actually a ternary operator containing the number `0.3`
1787+
bool isTernary = CharTypes::_C_DIG == this->charClassifier->GetCharType(this->PeekFirst(p + 1, last));
1788+
if (isTernary)
1789+
break;
1790+
17861791
p++;
17871792
token = tkOptChain;
17881793
break;

0 commit comments

Comments
 (0)