File tree Expand file tree Collapse file tree 2 files changed +63
-49
lines changed
src/com/google/javascript/jscomp/parsing/parser
test/com/google/javascript/jscomp/parsing Expand file tree Collapse file tree 2 files changed +63
-49
lines changed Original file line number Diff line number Diff line change @@ -1726,55 +1726,56 @@ private boolean peekStatement() {
1726
1726
*/
1727
1727
private boolean peekStatementStandard () {
1728
1728
switch (peekType ()) {
1729
- case OPEN_CURLY :
1730
- case VAR :
1731
- case CONST :
1732
- case SEMI_COLON :
1733
- case IF :
1734
- case DO :
1735
- case WHILE :
1736
- case FOR :
1737
- case CONTINUE :
1738
- case BREAK :
1739
- case RETURN :
1740
- case WITH :
1741
- case SWITCH :
1742
- case THROW :
1743
- case TRY :
1744
- case DEBUGGER :
1745
- case YIELD :
1746
- case IDENTIFIER :
1747
- case TYPE :
1748
- case DECLARE :
1749
- case MODULE :
1750
- case NAMESPACE :
1751
- case THIS :
1752
- case CLASS :
1753
- case SUPER :
1754
- case NUMBER :
1755
- case STRING :
1756
- case NO_SUBSTITUTION_TEMPLATE :
1757
- case TEMPLATE_HEAD :
1758
- case NULL :
1759
- case TRUE :
1760
- case SLASH : // regular expression literal
1761
- case SLASH_EQUAL : // regular expression literal
1762
- case FALSE :
1763
- case OPEN_SQUARE :
1764
- case OPEN_PAREN :
1765
- case NEW :
1766
- case DELETE :
1767
- case VOID :
1768
- case TYPEOF :
1769
- case PLUS_PLUS :
1770
- case MINUS_MINUS :
1771
- case PLUS :
1772
- case MINUS :
1773
- case TILDE :
1774
- case BANG :
1775
- return true ;
1776
- default :
1777
- return false ;
1729
+ case OPEN_CURLY :
1730
+ case VAR :
1731
+ case CONST :
1732
+ case SEMI_COLON :
1733
+ case IF :
1734
+ case DO :
1735
+ case WHILE :
1736
+ case FOR :
1737
+ case CONTINUE :
1738
+ case BREAK :
1739
+ case RETURN :
1740
+ case WITH :
1741
+ case SWITCH :
1742
+ case THROW :
1743
+ case TRY :
1744
+ case DEBUGGER :
1745
+ case YIELD :
1746
+ case IDENTIFIER :
1747
+ case TYPE :
1748
+ case DECLARE :
1749
+ case MODULE :
1750
+ case NAMESPACE :
1751
+ case THIS :
1752
+ case CLASS :
1753
+ case SUPER :
1754
+ case NUMBER :
1755
+ case BIGINT :
1756
+ case STRING :
1757
+ case NO_SUBSTITUTION_TEMPLATE :
1758
+ case TEMPLATE_HEAD :
1759
+ case NULL :
1760
+ case TRUE :
1761
+ case SLASH : // regular expression literal
1762
+ case SLASH_EQUAL : // regular expression literal
1763
+ case FALSE :
1764
+ case OPEN_SQUARE :
1765
+ case OPEN_PAREN :
1766
+ case NEW :
1767
+ case DELETE :
1768
+ case VOID :
1769
+ case TYPEOF :
1770
+ case PLUS_PLUS :
1771
+ case MINUS_MINUS :
1772
+ case PLUS :
1773
+ case MINUS :
1774
+ case TILDE :
1775
+ case BANG :
1776
+ return true ;
1777
+ default :
1778
+ return false ;
1778
1779
}
1779
1780
}
1780
1781
Original file line number Diff line number Diff line change @@ -3977,6 +3977,19 @@ public void testBigIntLiteralHex() {
3977
3977
assertNode (bigint ).isBigInt (new BigInteger ("15" ));
3978
3978
}
3979
3979
3980
+ @ Test
3981
+ public void testBigIntInFunctionStatement () {
3982
+ Node add =
3983
+ parse ("function f(/** @type {bigint} */ x) { 0n + x }" ) // SCRIPT
3984
+ .getOnlyChild () // FUNCTION
3985
+ .getLastChild () // BLOCK
3986
+ .getOnlyChild () // EXPR_RESULT
3987
+ .getOnlyChild (); // ADD
3988
+ assertNode (add ).hasToken (Token .ADD );
3989
+ assertNode (add .getFirstChild ()).isBigInt (BigInteger .ZERO );
3990
+ assertNode (add .getLastChild ()).isName ("x" );
3991
+ }
3992
+
3980
3993
@ Test
3981
3994
public void testBigIntLiteralErrors () {
3982
3995
parseError ("01n;" , "SyntaxError: nonzero BigInt can't have leading zero" );
You can’t perform that action at this time.
0 commit comments