Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for BigInt and 1234n/1234N constants #535

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# History of user-visible changes

## 2019-10-14
* Added support for BigInt and 1234n or 1234N constants.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put that under Next


## Next

* Emacs 27 now provides improved JSX indentation support, along with
Expand Down
6 changes: 5 additions & 1 deletion js2-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ are enabled, these will also be included.")

(defvar js2-harmony-externs
(mapcar 'symbol-name
'(Map Promise Proxy Reflect Set Symbol WeakMap WeakSet))
'(BigInt Map Promise Proxy Reflect Set Symbol WeakMap WeakSet))
"ES6 externs. If `js2-include-browser-externs' is enabled and
`js2-language-version' is sufficiently high, these will be included.")

Expand Down Expand Up @@ -6047,6 +6047,10 @@ its relevant fields and puts it into `js2-ti-tokens'."
(js2-add-to-string c)
(setq c (js2-get-char))
while (js2-digit-p c))))
;; BigInt constant (1234n or 1234N)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test maybe?

(when (and (memq c '(?n ?N))
(>= js2-language-version 200))
(setq c (js2-get-char)))
(js2-unget-char)
(let ((str (js2-set-string-from-buffer token)))
(setf (js2-token-number token) (js2-string-to-number str base)
Expand Down