Skip to content

Commit 1fe0414

Browse files
committed
Fix test262 error
- force evaluation order in `set_date_fields` - fix evaluation error in test262/test/built-ins/Date/UTC/fp-evaluation-order.js:19: unexpected error: Test262Error: precision in MakeDate Expected SameValue(«34448384», «34447360») to be true
1 parent ef4e7b2 commit 1fe0414

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

quickjs.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -49431,7 +49431,8 @@ static double time_clip(double t) {
4943149431
of the operations */
4943249432
static double set_date_fields(double fields[], int is_local) {
4943349433
int64_t y;
49434-
double days, d, h, m1;
49434+
double days, h, m1;
49435+
volatile double d; /* enforce evaluation order */
4943549436
int i, m, md;
4943649437

4943749438
m1 = fields[1];
@@ -49448,9 +49449,14 @@ static double set_date_fields(double fields[], int is_local) {
4944849449
days += md;
4944949450
}
4945049451
days += fields[2] - 1;
49452+
/* made d volatile to ensure order of evaluation as specified in ECMA.
49453+
* this fixes a test262 error on
49454+
* test262/test/built-ins/Date/UTC/fp-evaluation-order.js
49455+
*/
4945149456
h = fields[3] * 3600000 + fields[4] * 60000 +
4945249457
fields[5] * 1000 + fields[6];
49453-
d = days * 86400000 + h;
49458+
d = days * 86400000;
49459+
d = d + h;
4945449460
if (is_local)
4945549461
d += getTimezoneOffset(d) * 60000;
4945649462
return time_clip(d);

0 commit comments

Comments
 (0)