summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-10-17 08:05:28 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-10-17 08:05:28 -0700
commit2a0033ebad7883109bc2a2053986aeaed7be9525 (patch)
treed978d2981b3d8aef086cfa73aa1894d2132fac99
parente61bfc41ed9d522b8f679e758fe79f20b326b76b (diff)
downloadtxr-2a0033ebad7883109bc2a2053986aeaed7be9525.tar.gz
txr-2a0033ebad7883109bc2a2053986aeaed7be9525.tar.bz2
txr-2a0033ebad7883109bc2a2053986aeaed7be9525.zip
compiler: warn on too many lambda args.
* share/txr/stdlib/vm-param.tl (%max-lambda-fixed-args%): New symbol macro. * share/txr/stdlib/compiler.tl (compiler comp-lambda): If the nubmer of fixed parameters exceeds %max-lambda-fixed-args%, then issue a warning.
-rw-r--r--share/txr/stdlib/compiler.tl3
-rw-r--r--share/txr/stdlib/vm-param.tl1
2 files changed, 4 insertions, 0 deletions
diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl
index 0fdf77ba..2ddfeac5 100644
--- a/share/txr/stdlib/compiler.tl
+++ b/share/txr/stdlib/compiler.tl
@@ -819,6 +819,9 @@
(need-frame (or (plusp pars.nfix) pars.rest))
(nenv (if need-frame (new env up env co me) env))
lexsyms fvars specials need-dframe)
+ (when (> pars.nfix %max-lambda-fixed-args%)
+ (compile-warning form "~s arguments in a lambda (max is ~s)"
+ pars.nfix %max-lambda-fixed-args%))
(flet ((spec-sub (sym)
(cond
((special-var-p sym)
diff --git a/share/txr/stdlib/vm-param.tl b/share/txr/stdlib/vm-param.tl
index 93ec2363..498c144d 100644
--- a/share/txr/stdlib/vm-param.tl
+++ b/share/txr/stdlib/vm-param.tl
@@ -34,3 +34,4 @@
(defsymacro %max-sm-lev-idx% (macro-time (pred %sm-lev-size%)))
(defsymacro %max-sm-lev% 15)
(defsymacro %sm-lev-bits% 6)
+(defsymacro %max-lambda-fixed-args% 127)