guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 01/01: Fix (< 'foo) compilation


From: Andy Wingo
Subject: [Guile-commits] 01/01: Fix (< 'foo) compilation
Date: Tue, 21 Jun 2016 21:20:56 +0000 (UTC)

wingo pushed a commit to branch master
in repository guile.

commit 0472af4c580f378d75862cb30978bd13e101a89d
Author: Andy Wingo <address@hidden>
Date:   Tue Jun 21 23:17:25 2016 +0200

    Fix (< 'foo) compilation
    
    * module/language/tree-il/primitives.scm (expand-chained-comparisons):
      Fix (< 'foo) compilation.
    * test-suite/tests/compiler.test ("regression tests"): Add test case.
---
 module/language/tree-il/primitives.scm |    7 ++++++-
 test-suite/tests/compiler.test         |    6 +++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/module/language/tree-il/primitives.scm 
b/module/language/tree-il/primitives.scm
index 724f384..0a88f14 100644
--- a/module/language/tree-il/primitives.scm
+++ b/module/language/tree-il/primitives.scm
@@ -579,7 +579,12 @@
 (define (expand-chained-comparisons prim)
   (case-lambda
     ((src) (make-const src #t))
-    ((src a) (make-const src #t))
+    ((src a)
+     ;; (< x) -> (begin (< x 0) #t).  Residualizes side-effects from x
+     ;; and, for numeric comparisons, checks that x is a number.
+     (make-seq src
+               (make-primcall src prim (list a (make-const src 0)))
+               (make-const src #t)))
     ((src a b) #f)
     ((src a b . rest)
      (make-conditional src (make-primcall src prim (list a b))
diff --git a/test-suite/tests/compiler.test b/test-suite/tests/compiler.test
index b294912..bdae9a7 100644
--- a/test-suite/tests/compiler.test
+++ b/test-suite/tests/compiler.test
@@ -209,4 +209,8 @@
      '(begin
         (define x (list 1))
         (define x (car x))
-        x))))
+        x)))
+
+  (pass-if "Chained comparisons"
+    (not (compile
+          '(false-if-exception (< 'not-a-number))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]