1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-20 01:57:09 +03:00

guile: Fix crash/exception on literal empty list

Issue #190
This commit is contained in:
Dov Murik 2016-03-30 09:29:00 -04:00
parent 6f8a5d05fb
commit 81eabb9986
8 changed files with 11 additions and 0 deletions

View File

@ -58,6 +58,7 @@
(else (lp (cddr next) (cons (car next) k) (cons (cadr next) v))))))
(match ast
((? (lambda (x) (not (list? x)))) (eval_ast ast env))
(() ast)
(('def! k v) ((env 'set) k (EVAL v env)))
(('let* kvs body)
(let* ((new-env (make-Env #:outer env))

View File

@ -60,6 +60,7 @@
((null? (cdr next)) (throw 'mal-error "let*: Invalid binding form" kvs))
(else (lp (cddr next) (cons (car next) k) (cons (cadr next) v))))))
(match ast
(() ast)
(('def! k v) ((env 'set) k (EVAL v env)))
(('let* kvs body)
(let* ((new-env (make-Env #:outer env))

View File

@ -68,6 +68,7 @@
;; If you're Lispy enough, there's no recursive at all while you saw named let loop.
(let tco-loop((ast ast) (env env))
(match ast
(() ast)
(('def! k v) ((env 'set) k (EVAL v env)))
(('let* kvs body)
(let* ((new-env (make-Env #:outer env))

View File

@ -70,6 +70,7 @@
;; If you're Lispy enough, there's no recursive at all while you saw named let loop.
(let tco-loop((ast ast) (env env))
(match ast
(() ast)
(('def! k v) ((env 'set) k (EVAL v env)))
(('let* kvs body)
(let* ((new-env (make-Env #:outer env))

View File

@ -84,6 +84,7 @@
;; If you're Lispy enough, there's no recursive at all while you saw named let loop.
(let tco-loop((ast ast) (env env))
(match ast
(() ast)
(('quote obj) obj)
(('quasiquote obj) (EVAL (_quasiquote (->list obj)) env))
(('def! k v) ((env 'set) k (EVAL v env)))

View File

@ -54,6 +54,7 @@
(define (is_macro_call ast env)
(and (list? ast)
(> (length ast) 0)
(and=> (env-check (car ast) env) is-macro?)))
(define (_macroexpand ast env)
@ -91,6 +92,7 @@
(let ((ast (_macroexpand ast env)))
(match ast
((? non-list?) (eval_ast ast env))
(() ast)
(('defmacro! k v)
(let ((c (EVAL v env)))
(callable-is_macro-set! c #t)

View File

@ -55,6 +55,7 @@
(define (is_macro_call ast env)
(and (list? ast)
(> (length ast) 0)
(and=> (env-check (car ast) env) is-macro?)))
(define (_macroexpand ast env)
@ -95,6 +96,7 @@
(let ((ast (_macroexpand ast env)))
(match ast
((? non-list?) (eval_ast ast env))
(() ast)
(('defmacro! k v)
(let ((c (EVAL v env)))
(callable-is_macro-set! c #t)

View File

@ -69,6 +69,7 @@
(define (is_macro_call ast env)
(and (list? ast)
(> (length ast) 0)
(and=> (env-check (car ast) env) is-macro?)))
(define (_macroexpand ast env)
@ -107,6 +108,7 @@
(let ((ast (_macroexpand ast env)))
(match ast
((? non-list?) (eval_ast ast env))
(() ast)
(('defmacro! k v)
(let ((c (EVAL v env)))
(callable-is_macro-set! c #t)