Skip to content

Commit 12ba6f9

Browse files
committed
adjust argument checking for > and >=
If both arguments to `>` or `>=` are not real numbers, complain about the earlier argument. There's generally no guarantee about the order that arguments will be checked, but most checks are left-to-right, so it becomes expected by users. The checks for `>` and `>=` were backward only because they're implemented using `$<` and `$<=`. This small adjustment to error reporting should have minimal overall impact, since the adjustment is only only in the error case.
1 parent 0cd0ef0 commit 12ba6f9

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

mats/5_3.ms

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,7 @@
11371137
(error? (< 3.4+0.0i 3.5))
11381138
(error? (< 3.2 3.4+0.0i))
11391139
(error? (< 3.2 3.3 3.4+0.0i))
1140+
(error? (< 1.0+0.0i 0.0+2.0i))
11401141
(not (< 3 3))
11411142
(< 3 4)
11421143
(not (< -3 -3))
@@ -1197,6 +1198,7 @@
11971198
(error? (<= 3.4+0.0i 3.5))
11981199
(error? (<= 3.2 3.4+0.0i))
11991200
(error? (<= 3.2 3.3 3.4+0.0i))
1201+
(error? (<= 1.0+0.0i 0.0+2.0i))
12001202
(<= 3 3)
12011203
(<= 3 4)
12021204
(<= -3 -3)
@@ -1256,6 +1258,7 @@
12561258
(error? (> 3.4+0.0i 3.5))
12571259
(error? (> 3.2 3.4+0.0i))
12581260
(error? (> 3.2 3.3 3.4+0.0i))
1261+
(error? (> 1.0+0.0i 0.0+2.0i))
12591262
(not (> 3 3))
12601263
(not (> 3 4))
12611264
(not (> -3 -3))
@@ -1315,6 +1318,7 @@
13151318
(error? (>= 3.4+0.0i 3.5))
13161319
(error? (>= 3.2 3.4+0.0i))
13171320
(error? (>= 3.2 3.3 3.4+0.0i))
1321+
(error? (>= 1.0+0.0i 0.0+2.0i))
13181322
(>= 3 3)
13191323
(not (>= 3 4))
13201324
(>= -3 -3)
@@ -1417,6 +1421,7 @@
14171421
(error? (r6rs:< 'a 3 4))
14181422
(error? (r6rs:< 4 'a 3))
14191423
(error? (r6rs:< 3 5 'a 4))
1424+
(error? (r6rs:< 1.0+0.0i 0.0+2.0i))
14201425
(not (r6rs:< 3 3))
14211426
(r6rs:< 3 4)
14221427
(not (r6rs:< -3 -3))
@@ -1467,6 +1472,7 @@
14671472
(error? (r6rs:<= 'a 3 4))
14681473
(error? (r6rs:<= 4 'a 3))
14691474
(error? (r6rs:<= 3 5 'a 4))
1475+
(error? (r6rs:<= 1.0+0.0i 0.0+2.0i))
14701476
(r6rs:<= 3 3)
14711477
(r6rs:<= 3 4)
14721478
(r6rs:<= -3 -3)
@@ -1517,6 +1523,7 @@
15171523
(error? (r6rs:> 'a 3 4))
15181524
(error? (r6rs:> 4 'a 3))
15191525
(error? (r6rs:> 3 5 'a 4))
1526+
(error? (r6rs:> 1.0+0.0i 0.0+2.0i))
15201527
(not (r6rs:> 3 3))
15211528
(not (r6rs:> 3 4))
15221529
(not (r6rs:> -3 -3))
@@ -1567,6 +1574,7 @@
15671574
(error? (r6rs:>= 'a 3 4))
15681575
(error? (r6rs:>= 4 'a 3))
15691576
(error? (r6rs:>= 3 5 'a 4))
1577+
(error? (r6rs:>= 1.0+0.0i 0.0+2.0i))
15701578
(r6rs:>= 3 3)
15711579
(not (r6rs:>= 3 4))
15721580
(r6rs:>= -3 -3)

mats/root-experr-compile-0-f-f-f

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,7 @@ primvars.mo:Expected error in mat trace-output-port: "trace-output-port: #<input
10301030
5_3.mo:Expected error in mat <: "<: 3.4+0.0i is not a real number".
10311031
5_3.mo:Expected error in mat <: "<: 3.4+0.0i is not a real number".
10321032
5_3.mo:Expected error in mat <: "<: 3.4+0.0i is not a real number".
1033+
5_3.mo:Expected error in mat <: "<: 1.0+0.0i is not a real number".
10331034
5_3.mo:Expected error in mat <: "<: 2.0+1.0i is not a real number".
10341035
5_3.mo:Expected error in mat <: "<: 2+1i is not a real number".
10351036
5_3.mo:Expected error in mat <: "<: 3+1i is not a real number".
@@ -1050,6 +1051,7 @@ primvars.mo:Expected error in mat trace-output-port: "trace-output-port: #<input
10501051
5_3.mo:Expected error in mat <=: "<=: 3.4+0.0i is not a real number".
10511052
5_3.mo:Expected error in mat <=: "<=: 3.4+0.0i is not a real number".
10521053
5_3.mo:Expected error in mat <=: "<=: 3.4+0.0i is not a real number".
1054+
5_3.mo:Expected error in mat <=: "<=: 1.0+0.0i is not a real number".
10531055
5_3.mo:Expected error in mat <=: "<=: 2.0+1.0i is not a real number".
10541056
5_3.mo:Expected error in mat <=: "<=: 2+1i is not a real number".
10551057
5_3.mo:Expected error in mat <=: "<=: 3+1i is not a real number".
@@ -1070,6 +1072,7 @@ primvars.mo:Expected error in mat trace-output-port: "trace-output-port: #<input
10701072
5_3.mo:Expected error in mat >: ">: 3.4+0.0i is not a real number".
10711073
5_3.mo:Expected error in mat >: ">: 3.4+0.0i is not a real number".
10721074
5_3.mo:Expected error in mat >: ">: 3.4+0.0i is not a real number".
1075+
5_3.mo:Expected error in mat >: ">: 1.0+0.0i is not a real number".
10731076
5_3.mo:Expected error in mat >: ">: 2.0+1.0i is not a real number".
10741077
5_3.mo:Expected error in mat >: ">: 2+1i is not a real number".
10751078
5_3.mo:Expected error in mat >: ">: 3+1i is not a real number".
@@ -1090,6 +1093,7 @@ primvars.mo:Expected error in mat trace-output-port: "trace-output-port: #<input
10901093
5_3.mo:Expected error in mat >=: ">=: 3.4+0.0i is not a real number".
10911094
5_3.mo:Expected error in mat >=: ">=: 3.4+0.0i is not a real number".
10921095
5_3.mo:Expected error in mat >=: ">=: 3.4+0.0i is not a real number".
1096+
5_3.mo:Expected error in mat >=: ">=: 1.0+0.0i is not a real number".
10931097
5_3.mo:Expected error in mat >=: ">=: 2.0+1.0i is not a real number".
10941098
5_3.mo:Expected error in mat >=: ">=: 2+1i is not a real number".
10951099
5_3.mo:Expected error in mat >=: ">=: 3+1i is not a real number".
@@ -1111,6 +1115,7 @@ primvars.mo:Expected error in mat trace-output-port: "trace-output-port: #<input
11111115
5_3.mo:Expected error in mat r6rs:<: "<: a is not a real number".
11121116
5_3.mo:Expected error in mat r6rs:<: "<: a is not a real number".
11131117
5_3.mo:Expected error in mat r6rs:<: "<: a is not a real number".
1118+
5_3.mo:Expected error in mat r6rs:<: "<: 1.0+0.0i is not a real number".
11141119
5_3.mo:Expected error in mat r6rs:<: "<: 2.0+1.0i is not a real number".
11151120
5_3.mo:Expected error in mat r6rs:<: "<: 2+1i is not a real number".
11161121
5_3.mo:Expected error in mat r6rs:<: "<: 3+1i is not a real number".
@@ -1123,6 +1128,7 @@ primvars.mo:Expected error in mat trace-output-port: "trace-output-port: #<input
11231128
5_3.mo:Expected error in mat r6rs:<=: "<=: a is not a real number".
11241129
5_3.mo:Expected error in mat r6rs:<=: "<=: a is not a real number".
11251130
5_3.mo:Expected error in mat r6rs:<=: "<=: a is not a real number".
1131+
5_3.mo:Expected error in mat r6rs:<=: "<=: 1.0+0.0i is not a real number".
11261132
5_3.mo:Expected error in mat r6rs:<=: "<=: 2.0+1.0i is not a real number".
11271133
5_3.mo:Expected error in mat r6rs:<=: "<=: 2+1i is not a real number".
11281134
5_3.mo:Expected error in mat r6rs:<=: "<=: 3+1i is not a real number".
@@ -1135,6 +1141,7 @@ primvars.mo:Expected error in mat trace-output-port: "trace-output-port: #<input
11351141
5_3.mo:Expected error in mat r6rs:>: ">: a is not a real number".
11361142
5_3.mo:Expected error in mat r6rs:>: ">: a is not a real number".
11371143
5_3.mo:Expected error in mat r6rs:>: ">: a is not a real number".
1144+
5_3.mo:Expected error in mat r6rs:>: ">: 1.0+0.0i is not a real number".
11381145
5_3.mo:Expected error in mat r6rs:>: ">: 2.0+1.0i is not a real number".
11391146
5_3.mo:Expected error in mat r6rs:>: ">: 2+1i is not a real number".
11401147
5_3.mo:Expected error in mat r6rs:>: ">: 3+1i is not a real number".
@@ -1147,6 +1154,7 @@ primvars.mo:Expected error in mat trace-output-port: "trace-output-port: #<input
11471154
5_3.mo:Expected error in mat r6rs:>=: ">=: a is not a real number".
11481155
5_3.mo:Expected error in mat r6rs:>=: ">=: a is not a real number".
11491156
5_3.mo:Expected error in mat r6rs:>=: ">=: a is not a real number".
1157+
5_3.mo:Expected error in mat r6rs:>=: ">=: 1.0+0.0i is not a real number".
11501158
5_3.mo:Expected error in mat r6rs:>=: ">=: 2.0+1.0i is not a real number".
11511159
5_3.mo:Expected error in mat r6rs:>=: ">=: 2+1i is not a real number".
11521160
5_3.mo:Expected error in mat r6rs:>=: ">=: 3+1i is not a real number".

s/5_3.ss

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,7 +2379,12 @@
23792379
[(fixnum?) (if (fixnum-floatable-wlop? y) (fl< x (fixnum->flonum y)) (exact-inexact-compare? > y x))]
23802380
[(bignum? ratnum?) (exact-inexact-compare? > y x)]
23812381
[else (nonreal-error who y)])]
2382-
[else (nonreal-error who x)])))
2382+
[else (when (and (eq? who '>)
2383+
;; arguments were reversed; call in other order to
2384+
;; check original first argument first
2385+
(not (real? y)))
2386+
(nonreal-error who y))
2387+
(nonreal-error who x)])))
23832388

23842389
(set! $<=
23852390
(lambda (who x y)
@@ -2415,7 +2420,12 @@
24152420
[(fixnum?) (if (fixnum-floatable-wlop? y) (fl<= x (fixnum->flonum y)) (exact-inexact-compare? >= y x))]
24162421
[(bignum? ratnum?) (exact-inexact-compare? >= y x)]
24172422
[else (nonreal-error who y)])]
2418-
[else (nonreal-error who x)])))
2423+
[else (when (and (eq? who '>=)
2424+
;; arguments were reversed; call in other order to
2425+
;; check original first argument first
2426+
(not (real? y)))
2427+
(nonreal-error who y))
2428+
(nonreal-error who x)])))
24192429

24202430
(set! $+
24212431
(lambda (who x y)

0 commit comments

Comments
 (0)