1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 20:00:19 +02:00

Explicitly test for undefined arguments to handle false values like 0

This commit is contained in:
Ian Price 2015-06-24 19:57:28 +01:00
parent b631576f13
commit 89029a54f4
3 changed files with 52 additions and 8 deletions

View file

@ -104,10 +104,13 @@
(define (bind-opt-args opts num-drop)
(map (lambda (opt idx)
(make-var (rename-id opt)
(make-binop 'or
(make-refine (make-id "arguments")
(make-const (+ num-drop idx)))
(make-refine *scheme* (make-const "UNDEFINED")))))
(let ((arg (make-refine (make-id "arguments")
(make-const (+ num-drop idx)))))
(make-ternary (make-binop '===
(make-prefix 'typeof arg)
(make-id "undefined"))
(make-refine *scheme* (make-const "UNDEFINED"))
arg))))
opts
(iota (length opts))))