From 2a0033ebad7883109bc2a2053986aeaed7be9525 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 17 Oct 2019 08:05:28 -0700 Subject: 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. --- share/txr/stdlib/compiler.tl | 3 +++ share/txr/stdlib/vm-param.tl | 1 + 2 files changed, 4 insertions(+) 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) -- cgit v1.2.3