From 4a3c68a7d3ad032640db140e82ebe1728b4144f4 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Thu, 1 Feb 2018 17:42:05 -0500 Subject: [PATCH] Prevent a compiler error when there is only one argument to `+` or `*`. --- CHANGELOG.md | 1 + scheme/cyclone/primitives.sld | 2 ++ tests/match-tests.scm | 9 ++------- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f910bb1..864096ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Bug Fixes - Made several improvements to macro hygiene by renaming local variable bindings during expansion. Added a unit test module covering many test cases. - Fixed many functions including `utf8->string`, `string->utf8`, `bytevector-copy`, `list->vector`, and `list->string` to heap allocate objects that exceed the maximum size for objects on the stack. +- Prevent a compiler error when there is only one argument to `+` or `*`. ## 0.7.1 - December 21, 2017 diff --git a/scheme/cyclone/primitives.sld b/scheme/cyclone/primitives.sld index 6654cdc9..30bcc279 100644 --- a/scheme/cyclone/primitives.sld +++ b/scheme/cyclone/primitives.sld @@ -910,6 +910,8 @@ (define (prim:inline-convert-prim-call prim-call) (cond + ((and (equal? (car prim-call) '+) (= (length prim-call) 2)) `(Cyc-fast-plus 0 ,@(cdr prim-call))) + ((and (equal? (car prim-call) '*) (= (length prim-call) 2)) `(Cyc-fast-mul 1 ,@(cdr prim-call))) ((equal? (car prim-call) '+) (->dyadic (cons 'Cyc-fast-plus (cdr prim-call)))) ((equal? (car prim-call) '*) (->dyadic (cons 'Cyc-fast-mul (cdr prim-call)))) ((and (equal? (car prim-call) '-) (= (length prim-call) 2)) `(Cyc-fast-sub 0 ,@(cdr prim-call))) ;; Special case, fast negation diff --git a/tests/match-tests.scm b/tests/match-tests.scm index d4afe7f5..40c0891f 100644 --- a/tests/match-tests.scm +++ b/tests/match-tests.scm @@ -95,13 +95,8 @@ (match lst ;(() 0) -;; Temporarily commenting these 2 lines out to track down compiler error with the next: -; (((? number? n) (or 's 'seconds 'sec) . rest) -; (+ 0 (* #e1 n) (calc-time rest))) - ;; TODO: interesting compiler error with these lines: - (((? number? n) (or 's 'seconds 'sec) ) ;. rest) - (+ (* #e1 n) )) ;(calc-time rest))) -;; + (((? number? n) (or 's 'seconds 'sec) . rest) + (+ 0 (* #e1 n) (calc-time rest))) (((? number? n) (or 'm 'min 'minutes) . rest) (+ (* #e60 n) (calc-time rest))) (((? number? n) (or 'hours 'h) . rest)