about summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorCharlie Gordon <github@chqrlie.org>2024-02-12 18:37:37 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-02 18:12:23 +0100
commit7e3ce0701a838bc01939996d1df9411961441457 (patch)
tree2d69818bd8b62ab21644b28996db5f11fdcbe077 /lib
parent00757d71489dd07a23c2e2fbc63f9bbdb5833fd1 (diff)
downloadchawan-7e3ce0701a838bc01939996d1df9411961441457.tar.gz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/quickjs/quickjs.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/quickjs/quickjs.c b/lib/quickjs/quickjs.c
index 40329b23..5f031f3c 100644
--- a/lib/quickjs/quickjs.c
+++ b/lib/quickjs/quickjs.c
@@ -49539,7 +49539,8 @@ static double time_clip(double t) {
    of the operations */
 static double set_date_fields(double fields[], int is_local) {
     int64_t y;
-    double days, d, h, m1;
+    double days, h, m1;
+    volatile double d;  /* enforce evaluation order */
     int i, m, md;
 
     m1 = fields[1];
@@ -49556,9 +49557,14 @@ static double set_date_fields(double fields[], int is_local) {
         days += md;
     }
     days += fields[2] - 1;
+    /* made d volatile to ensure order of evaluation as specified in ECMA.
+     * this fixes a test262 error on
+     * test262/test/built-ins/Date/UTC/fp-evaluation-order.js
+     */
     h = fields[3] * 3600000 + fields[4] * 60000 +
         fields[5] * 1000 + fields[6];
-    d = days * 86400000 + h;
+    d = days * 86400000;
+    d = d + h;
     if (is_local)
         d += getTimezoneOffset(d) * 60000;
     return time_clip(d);