Bug 142681 - ES6: Add binary and octal literal support
Summary: ES6: Add binary and octal literal support
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 312.x
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Michael Saboff
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-13 16:02 PDT by Michael Saboff
Modified: 2015-03-14 09:29 PDT (History)
4 users (show)

See Also:


Attachments
Patch (23.04 KB, patch)
2015-03-13 17:44 PDT, Michael Saboff
rniwa: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Saboff 2015-03-13 16:02:05 PDT
Add support for binary and octal numeric literals including in strings passed to toNumber().
Comment 1 Michael Saboff 2015-03-13 17:44:11 PDT
Created attachment 248627 [details]
Patch
Comment 2 Joseph Pecoraro 2015-03-13 18:41:37 PDT
Comment on attachment 248627 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=248627&action=review

Looks good to me! Added a few suggestions for more tests.

> Source/JavaScriptCore/parser/Lexer.cpp:1754
> +                m_lexErrorMessage = ASCIILiteral("No space between binary literal and identifier");

I don't see the error message below. We should add a test for these error cases.

    0b1myVariable => SyntaxError: No space between binary literal and identifier
    0o1myVariable => SyntaxError: No space between octal literal and identifier

> Source/WTF/ChangeLog:12
> +2015-03-13  Michael Saboff  <msaboff@apple.com>

Oops, double changelog.

> LayoutTests/js/octal-literals-expected.txt:19
> +PASS 0o777777777777777777 is 18014398509481984

I think we should probably test the extreme case as well:

For example "0o100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" being some very large exponent, and then eventually just "Infinity". Absurd for binary literals but still can be tested.
Comment 3 Ryosuke Niwa 2015-03-13 19:30:53 PDT
Comment on attachment 248627 [details]
Patch

r=me although you probably want to address Joe's comments.
Comment 4 Michael Saboff 2015-03-14 08:41:05 PDT
(In reply to comment #2)
> Comment on attachment 248627 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=248627&action=review
> 
> Looks good to me! Added a few suggestions for more tests.
> 
> > Source/JavaScriptCore/parser/Lexer.cpp:1754
> > +                m_lexErrorMessage = ASCIILiteral("No space between binary literal and identifier");
> 
> I don't see the error message below. We should add a test for these error
> cases.
> 
>     0b1myVariable => SyntaxError: No space between binary literal and
> identifier
>     0o1myVariable => SyntaxError: No space between octal literal and
> identifier

Added.

> > Source/WTF/ChangeLog:12
> > +2015-03-13  Michael Saboff  <msaboff@apple.com>
> 
> Oops, double changelog.

Fixed.

> > LayoutTests/js/octal-literals-expected.txt:19
> > +PASS 0o777777777777777777 is 18014398509481984
> 
> I think we should probably test the extreme case as well:
> 
> For example
> "0o10000000000000000000000000000000000000000000000000000000000000000000000000
> 00000000000000000000000000000000000000000000000000000000000000000000000000000
> 00000000000000000000000000000000000000000000000000000000000000000000000000000
> 000000000000000000000000000000000000000000000000000000000" being some very
> large exponent, and then eventually just "Infinity". Absurd for binary
> literals but still can be tested.

Added.
Comment 5 Michael Saboff 2015-03-14 09:29:50 PDT
Committed r181497: <http://trac.webkit.org/changeset/181497>