-
Notifications
You must be signed in to change notification settings - Fork 158
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
Example where lack of object shape checks in ToTemporalTimeZone and ToCalendar can be confusing #2354
Comments
Yikes, that's an easy trap to fall into, for sure. This is indeed an intentional design choice, but as I mentioned in the other issue: if this is causing problems in the implementation, especially with respect to optimizability, I think we should put it on the agenda to discuss in a Temporal champions meeting. |
Seems like a good thing to fix. Obvious bug that's easy to encounter. |
We had a bit of discussion on this in the Temporal champions meeting of 2022-10-13 and have a temperature check for some possible solutions:
We'll discuss this again in the future. |
I continue to feel pretty strongly that required args should be positional whenever possible, which seems to conflict with option 3. |
Champions meeting 2022-10-27: We'll go with #4 above:
|
In order to prevent bugs like `new Temporal.ZonedDateTime(0n, cal, tz)` (where the calendar and time zone arguments are switched, silently poisoning the object) ToTemporalCalendar should throw if it encounters a Temporal.TimeZone instance, and ToTemporalTimeZone should throw if it encounters a Temporal.Calendar instance. Includes implementation in the reference code. Co-authored-by: Aditi <aditisingh1400@gmail.com> Closes: #2354
In order to prevent bugs like `new Temporal.ZonedDateTime(0n, cal, tz)` (where the calendar and time zone arguments are switched, silently poisoning the object) ToTemporalCalendar should throw if it encounters a Temporal.TimeZone instance, and ToTemporalTimeZone should throw if it encounters a Temporal.Calendar instance. Includes implementation in the reference code. Co-authored-by: Aditi <aditisingh1400@gmail.com> Closes: #2354
Probably just a FYI, because the underlying issue was already reported in #1652, which in turn links to #300 and #1294.
I was recently writing this incorrect code:
timeZone
andcalendar
were passed in the wrong order, which leads to an error only after some methods onzdt.[[TimeZone]]
orzdt.[[Calendar]]
are called:Directly catching this mistake when creating the
ZonedDateTime
would be nicer, but I'm not sure how to best detect this case, given that accepting any object for the time zone and calendar arguments was an intentional design choice.The text was updated successfully, but these errors were encountered: