mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-21 14:49:17 +02:00
Issue #336 - Validate num of args passed to if
This commit is contained in:
parent
b482a40f04
commit
02fa091297
2 changed files with 14 additions and 7 deletions
|
@ -7,6 +7,7 @@ https://github.com/cyclone-scheme/cyclone-winds
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
|
|
||||||
|
- Validate the number of arguments passed to `if` expressions.
|
||||||
- Raise a useful error instead of aborting the whole program (!) when apply attempts to execute an object of the wrong type.
|
- Raise a useful error instead of aborting the whole program (!) when apply attempts to execute an object of the wrong type.
|
||||||
- Better handling of edge cases where an object of the wrong type is executed instead of a closure. Previously there were cases where this would cause the runtime to crash.
|
- Better handling of edge cases where an object of the wrong type is executed instead of a closure. Previously there were cases where this would cause the runtime to crash.
|
||||||
|
|
||||||
|
|
|
@ -547,13 +547,19 @@
|
||||||
'ok))
|
'ok))
|
||||||
|
|
||||||
(define (analyze-if exp a-env rename-env local-renamed)
|
(define (analyze-if exp a-env rename-env local-renamed)
|
||||||
|
(let ((args (length exp)))
|
||||||
|
(cond
|
||||||
|
((< args 3)
|
||||||
|
(error "Not enough arguments" exp))
|
||||||
|
((> args 4)
|
||||||
|
(error "Too many arguments" exp)))
|
||||||
(let ((pproc (analyze (if-predicate exp) a-env rename-env local-renamed))
|
(let ((pproc (analyze (if-predicate exp) a-env rename-env local-renamed))
|
||||||
(cproc (analyze (if-consequent exp) a-env rename-env local-renamed))
|
(cproc (analyze (if-consequent exp) a-env rename-env local-renamed))
|
||||||
(aproc (analyze (if-alternative exp) a-env rename-env local-renamed)))
|
(aproc (analyze (if-alternative exp) a-env rename-env local-renamed)))
|
||||||
(lambda (env)
|
(lambda (env)
|
||||||
(if (pproc env)
|
(if (pproc env)
|
||||||
(cproc env)
|
(cproc env)
|
||||||
(aproc env)))))
|
(aproc env))))))
|
||||||
|
|
||||||
(define (analyze-lambda exp a-env rename-env local-renamed)
|
(define (analyze-lambda exp a-env rename-env local-renamed)
|
||||||
(let* ((vars (lambda-parameters exp))
|
(let* ((vars (lambda-parameters exp))
|
||||||
|
|
Loading…
Add table
Reference in a new issue