-
Notifications
You must be signed in to change notification settings - Fork 72
Temporal intrinsic #876
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
base: main
Are you sure you want to change the base?
Temporal intrinsic #876
Conversation
db6b7c0 to
5ceba18
Compare
f9ced65 to
2d81989
Compare
…ntPrototype%Temporal.Instant.Prototype% as well as heap data and handles
…type.rs and instant_constructor.rs
…dwork for Temporal.PlainTime, WIP Temporal.prototype.round implementations.. probably should have committed more frequently lol
93a45c0 to
20d4473
Compare
plain_time constructor and prototype structs and stubs
…pe of the pull request
aapoalas
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.
A partial review.
| weak-refs = [] | ||
| set = [] | ||
| typescript = [] | ||
| temporal = ["temporal_rs"] |
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.
issue: Feature is doubled.
| /// an integer or a throw completion. | ||
| /// It converts argument to an integer representing its Number value, | ||
| /// or throws a RangeError when that value is not integral. | ||
| pub(crate) fn to_integer_if_integral<'gc>( |
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.
nitpick: Should be gated on the feature flag.
| if let Value::Integer(digits_value) = digits_value | ||
| && (0..=9).contains(&digits_value.into_i64()) | ||
| { | ||
| return Ok(temporal_rs::parsers::Precision::Digit( |
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.
nitpick: Maybe add a small comment regarding this fast path.
| // b. Return auto. | ||
| return Ok(temporal_rs::parsers::Precision::Auto); | ||
| } | ||
| // SAFETY: not shared. |
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.
issue: You should be throwing an error here. "If not 'auto', throw a RangeError exception. Else, return 'auto'."
| )); | ||
| } | ||
| // 3. If digitsValue is not a Number, then | ||
| if !digits_value.is_number() { |
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.
suggestion:
| if !digits_value.is_number() { | |
| let Ok(digits_value) = Number::try_from(digits_value) else { |
This should work to convert digitsValue into a number after this if branch; you just need to add the currently missing "throw RangeError" part inside the else.
| } | ||
| // 3. If digitsValue is not a Number, then | ||
| if !digits_value.is_number() { | ||
| let scoped_digits_value = digits_value.scope(agent, gc.nogc()); |
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.
note: This scoping becomes unnecessary.
| )); | ||
| } | ||
| // 5. Let digitCount be floor(ℝ(digitsValue)). | ||
| let digit_count = digits_value |
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.
issue: ToNumber here is extra. Spec's R(digitsValue) means effectively digits_value.to_real(agent) which is equivalent to into_f64.
|
|
||
| impl DurationHeapData<'_> { | ||
| pub fn default() -> Self { | ||
| todo!() |
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.
issue: This is either dead code or will crash the program when Temporal.Duration is used :)
No description provided.