-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add "infinity", "negativeInfinity", and "nan" keywords to rfwtxt. #5899
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
Conversation
| if (identifier == 'false') { | ||
| _advance(); | ||
| return false; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these identifiers be added to the reserved words list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a blocking comment. These identifiers need to be added to the reserved words list; otherwise they could get shadowed by builders (when landed) by doing something like
Builder(
builder: (infinity) => Container(width: infinity.width),
),
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. If we add them to the reserved words list then this becomes a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if something like flutter/flutter#141833 (comment) would be useful here as well (instead of changing the language). The implementation of number could be as follows.
final result = _fetch(...);
if (result is int) return result as int;
if (result is double) return result as double;
if (result == 'infinity') return double.infinity;
if (result == 'nan') return double.nan;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would similarly be a breaking change though.
| repository: https://github.com/flutter/packages/tree/main/packages/rfw | ||
| issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+rfw%22 | ||
| version: 1.0.16 | ||
| version: 1.0.19 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this expected? Why are 2 versions being skipped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have a bunch of other PRs for this package and gave them all different numbers. I'll pick the right one when I land it. :-)
| expect(parseDataFile('{ "a": -1e-19 }'), <String, Object?>{ 'a': -0.0000000000000000001 }); | ||
| expect(parseDataFile('{ "a": infinity }'), <String, Object?>{ 'a': double.infinity }); | ||
| expect(parseDataFile('{ "a": negativeInfinity }'), <String, Object?>{ 'a': double.negativeInfinity }); | ||
| expect(parseDataFile('{ "a": nan }')['a'], isNaN); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: For the sake of consistency, should this particular test be
expect(..., <String, Object?> { 'a': double.nan });
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that would fail, because double.nan == double.nan is false
peixinli
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this!
|
We could make infinity and negative infinity be written as |
|
We could also use |
canceling lgtm to make sure i don't accidentally land this with the breaking change
|
From triage: what's the status of this PR? Should it be a Draft? |
|
There doesn't seem to be a huge amount of interest here so I'm tempted to just close it for now until we have a clearer need. |
|
closing per last comment. If you would like this feature please file a bug and cc me. Thanks! |
Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style.///).