Skip to content

Commit

Permalink
Don't break ternary with decimal numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
ShortDevelopment committed Apr 15, 2024
1 parent 0be5195 commit 2cd550c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/Parser/Scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1783,6 +1783,11 @@ tokens Scanner<EncodingPolicy>::ScanCore(bool identifyKwds)
}
else if (m_scriptContext->GetConfig()->IsESOptionalChainingEnabled() && this->PeekFirst(p, last) == '.')
{
// `a?.3:0` is actually a ternary operator containing the number `0.3`
bool isTernary = CharTypes::_C_DIG == this->charClassifier->GetCharType(this->PeekFirst(p + 1, last));
if (isTernary)
break;

p++;
token = tkOptChain;
break;
Expand Down

0 comments on commit 2cd550c

Please sign in to comment.