diff options
author | Ludovic Courtès <ludo@gnu.org> | 2013-01-26 19:18:31 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2013-01-26 19:18:31 +0100 |
commit | ed7c4a5d777bcff78512f1f1f9f2847ade90af11 (patch) | |
tree | 41f67c43c1008dabc8206968d062286245f221be /module/language/ecmascript | |
parent | 4ff2133aa16a29347149ff04225fb4649256e9c9 (diff) | |
download | guile-ed7c4a5d777bcff78512f1f1f9f2847ade90af11.tar.gz |
ecmascript: Fix conversion to boolean for non-numbers.
* module/language/ecmascript/base.scm (->boolean): Call `zero?' and
`nan?' only when X is a number.
* test-suite/tests/ecmascript.test ("compiler"): Add test case.
Diffstat (limited to 'module/language/ecmascript')
-rw-r--r-- | module/language/ecmascript/base.scm | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/module/language/ecmascript/base.scm b/module/language/ecmascript/base.scm index 6f5c65ba5..ac8493dd0 100644 --- a/module/language/ecmascript/base.scm +++ b/module/language/ecmascript/base.scm @@ -1,6 +1,6 @@ ;;; ECMAScript for Guile -;; Copyright (C) 2009 Free Software Foundation, Inc. +;; Copyright (C) 2009, 2013 Free Software Foundation, Inc. ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -168,7 +168,8 @@ x)) (define (->boolean x) - (not (or (not x) (null? x) (eq? x *undefined*) (zero? x) (nan? x) + (not (or (not x) (null? x) (eq? x *undefined*) + (and (number? x) (or (zero? x) (nan? x))) (and (string? x) (= (string-length x) 0))))) (define (->number x) |