Skip to content

Commit 8e9abda

Browse files
Config flag
1 parent b2f5f1b commit 8e9abda

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

lib/Common/ConfigFlagsList.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,7 @@ PHASE(All)
673673
#define DEFAULT_CONFIG_ESArrayFindFromLast (true)
674674
#define DEFAULT_CONFIG_ESPromiseAny (true)
675675
#define DEFAULT_CONFIG_ESNullishCoalescingOperator (true)
676+
#define DEFAULT_CONFIG_ESOptionalChaining (true)
676677
#define DEFAULT_CONFIG_ESGlobalThis (true)
677678

678679
// Jitting generators has not been tested on ARM
@@ -1199,6 +1200,9 @@ FLAGR(Boolean, ESNumericSeparator, "Enable Numeric Separator flag", DEFAULT_CONF
11991200
// ES Nullish coalescing operator support (??)
12001201
FLAGR(Boolean, ESNullishCoalescingOperator, "Enable nullish coalescing operator", DEFAULT_CONFIG_ESNullishCoalescingOperator)
12011202

1203+
// ES Optional chaining operator support (?.)
1204+
FLAGR(Boolean, ESOptionalChaining, "Enable optional chaining operator", DEFAULT_CONFIG_ESOptionalChaining)
1205+
12021206
// ES Hashbang support for interpreter directive syntax
12031207
FLAGR(Boolean, ESHashbang, "Enable Hashbang syntax", DEFAULT_CONFIG_ESHashbang)
12041208

lib/Parser/Scan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,7 @@ tokens Scanner<EncodingPolicy>::ScanCore(bool identifyKwds)
17811781
token = tkCoalesce;
17821782
break;
17831783
}
1784-
else if (this->PeekFirst(p, last) == '.') // ToDo: Config flag for optional chaining?!
1784+
else if (m_scriptContext->GetConfig()->IsESOptionalChainingEnabled() && this->PeekFirst(p, last) == '.')
17851785
{
17861786
p++;
17871787
token = tkOptChain;

lib/Runtime/Base/ThreadConfigFlagsList.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ FLAG_RELEASE(IsESBigIntEnabled, ESBigInt)
4545
FLAG_RELEASE(IsESNumericSeparatorEnabled, ESNumericSeparator)
4646
FLAG_RELEASE(IsESHashbangEnabled, ESHashbang)
4747
FLAG_RELEASE(IsESNullishCoalescingOperatorEnabled, ESNullishCoalescingOperator)
48+
FLAG_RELEASE(IsESOptionalChainingEnabled, ESOptionalChaining)
4849
FLAG_RELEASE(IsESExportNsAsEnabled, ESExportNsAs)
4950
FLAG_RELEASE(IsESSymbolDescriptionEnabled, ESSymbolDescription)
5051
FLAG_RELEASE(IsESPromiseAnyEnabled, ESPromiseAny)

0 commit comments

Comments
 (0)