mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-14 08:17:35 +02:00
Be more careful about identifying macros
The validation for number of function arguments was modified previously to filter-out macros, but the logic was not good enough. For some reason (need to track it down) non-macros are showing up in the macro environment. So additional logic is needed to confirm whether a given symbol is in fact a macro.
This commit is contained in:
parent
819151b7a4
commit
3c37c164fe
1 changed files with 9 additions and 1 deletions
|
@ -2388,14 +2388,22 @@
|
||||||
;; FUTURE (?): Does given symbol define a procedure?
|
;; FUTURE (?): Does given symbol define a procedure?
|
||||||
;(define (avld:procedure? sym) #f)
|
;(define (avld:procedure? sym) #f)
|
||||||
|
|
||||||
|
;; Predicate: Does given symbol refer to a macro?
|
||||||
|
(define (is-macro? sym)
|
||||||
|
(and-let* ((val (env:lookup sym (macro:get-env) #f)))
|
||||||
|
(or (tagged-list? 'macro val)
|
||||||
|
(Cyc-macro? val))))
|
||||||
|
|
||||||
;; Does the given function call pass enough arguments?
|
;; Does the given function call pass enough arguments?
|
||||||
(define (validate:num-function-args ast)
|
(define (validate:num-function-args ast)
|
||||||
|
;;(trace:error `(validate:num-function-args ,(car ast) ,ast ,(env:lookup (car ast) (macro:get-env) #f)))
|
||||||
(and-let* (((app? ast))
|
(and-let* (((app? ast))
|
||||||
;; Prims are checked elsewhere
|
;; Prims are checked elsewhere
|
||||||
((not (prim? (car ast))))
|
((not (prim? (car ast))))
|
||||||
((ref? (car ast)))
|
((ref? (car ast)))
|
||||||
;; Do not validate macros
|
;; Do not validate macros
|
||||||
((not (env:lookup (car ast) (macro:get-env) #f)))
|
((not (is-macro? (car ast))))
|
||||||
|
;; Extract lambda definition
|
||||||
(var (adb:get/default (car ast) #f))
|
(var (adb:get/default (car ast) #f))
|
||||||
(lam* (adbv:assigned-value var))
|
(lam* (adbv:assigned-value var))
|
||||||
((pair? lam*))
|
((pair? lam*))
|
||||||
|
|
Loading…
Add table
Reference in a new issue