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

Tracking issue for platform specific integer literals #33282

Open
5 of 10 tasks
leafpetersen opened this issue May 30, 2018 · 4 comments
Open
5 of 10 tasks

Tracking issue for platform specific integer literals #33282

leafpetersen opened this issue May 30, 2018 · 4 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language).

Comments

@leafpetersen
Copy link
Member

leafpetersen commented May 30, 2018

This is the meta-issue for platform specific integer literals. See #33160 for background discussion.

The decided upon course of action is here: #33160 (comment) (also summarized below).

TODO:
Step 1: (For Dart 2 release):

Step 2: (Post Dart 2):

  • kernel: allow all integer literals which can be exactly represented as a double when compiling for a JS platform
  • kernel: emit errors for literals which cannot be exactly represented using the platform integer
  • analyzer: allow all integer literals which can be exactly represented as a double when compiling for a JS platform
  • analyzer: emit errors for literals which cannot be exactly represented using the platform integer
  • analyzer: lint for cross platform integer literals
@leafpetersen
Copy link
Member Author

More details, copied over from #33160 (comment) .

Step 1 - In the Dart 2 timeframe:

  • It is an error if a literal is not exactly representable in 64 bits (current errors and warning)
  • Literals are interpreted as platform numbers (option 2 above)
    • So for example 0xffffffff00000000 will denote a different value on different platforms.
  • dart2js and DDC will report errors if a literal cannot be represented exactly in JS

Step 2 - In the post Dart 2 timeframe:

  • It is an error if a literal is not exactly representable in 64 bits when compiling to native
  • It is an error if a literal is not exactly representable as a double when compiling to JS
  • It may be desirable to have an opt-in int to warn if any literal is not in the intersection of the two

An implication of all of this is that we have (more) platform specific errors and warnings. In the short term, these will only be surfaced by the compilers. The analyzer/IDE may or may not choose to offer a way to select a platform for additional errors and warnings.

Implementation implications:

Step 1:

  • Requires no further work from kernel, except to guarantee that it does no incorrect-for-the-platform constant folding (which it already must guarantee)
  • Requires no further work from the analyzer (modulo existing bugs in platform correct constant evaluation)
  • Requires DDC and dart2js to warn if a literal is not exactly representable in JS

Step 2:

  • Requires kernel to support literals that cannot be represented as 64 bit integers (at least when compiling to JS)
  • Requires the analyzer/IDE to either stop warning on literals that exceed 64 bits, or else provide a platform selection mechanism to allow the correct set of errors and warnings to be surfaced.

@leafpetersen
Copy link
Member Author

cc @lrhn

@dgrove dgrove added this to the Dart2Stable milestone May 31, 2018
@dgrove
Copy link
Contributor

dgrove commented May 31, 2018

Because this will not be complete for Dart2Stable, dropping the milestone (all sub-issues needed for Dart2Stable are marked for the Dart2Stable milestone)

@srawlins
Copy link
Member

srawlins commented Jul 3, 2018

There should be a step to announce this breaking change as well.

dart-bot pushed a commit that referenced this issue Jul 3, 2018
Bug: #33282
Change-Id: I50d1a8855e83996777b8b8e051cd4171d5a8a9aa
Reviewed-on: https://dart-review.googlesource.com/63664
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Dana-Ferguson added a commit to Dana-Ferguson/time_machine that referenced this issue Jul 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language).
Projects
None yet
Development

No branches or pull requests

3 participants