diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-02-10 05:04:36 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-02-10 05:04:36 -0800 |
commit | 0f8e8e539d8c9c160e5832ccd20a72bd9038d023 (patch) | |
tree | b938025e506579df69e004fcf806192c07b1572c /share | |
parent | 70c07bc501f560f09fa52c6a754fabc8f905860f (diff) | |
download | txr-0f8e8e539d8c9c160e5832ccd20a72bd9038d023.tar.gz txr-0f8e8e539d8c9c160e5832ccd20a72bd9038d023.tar.bz2 txr-0f8e8e539d8c9c160e5832ccd20a72bd9038d023.zip |
awk macro: warn about invalid function use in rng.
Improving the new feature to handle functions also,
and improve the diagnostic by reporting the specific
to or from subform of which contains the reference.
* share/txr/stdlib/awk.tl (sys:awk-code-move-check): Take a
an argument indicating the kinds of bindings being checked,
symbols or functions, and an extra form argument.
(sys:awk-mac-let): Pass new arguments to
sys:awk-code-move-check and also call it two more times
to report on functions also.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/awk.tl | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/share/txr/stdlib/awk.tl b/share/txr/stdlib/awk.tl index 4808cb45..5b19e706 100644 --- a/share/txr/stdlib/awk.tl +++ b/share/txr/stdlib/awk.tl @@ -268,12 +268,13 @@ awc.cond-actions (nreverse awc.cond-actions)) awc)) -(defun sys:awk-code-move-check (awc aws-sym form suspicious-vars) +(defun sys:awk-code-move-check (awc aws-sym mainform subform + suspicious-vars kind) (when suspicious-vars - (compile-warning form "~!form ~s\n\ - is moved out of the apparent scope\n\ - and thus cannot refer to variables ~s" - form suspicious-vars))) + (compile-warning mainform "~!form ~s\n\ + is moved out of the apparent scope\n\ + and thus cannot refer to ~s ~s" + subform kind suspicious-vars))) (defmacro sys:awk-mac-let (awc aws-sym . body) ^(symacrolet ((rec (rslot ,aws-sym 'rec 'rec-to-f)) @@ -303,16 +304,30 @@ (flag-old (gensym)) (flag-new (gensym))) (tree-bind ((from-expr-ex fe-fv fe-ff fe-ev fe-ef) - (to-expr-ex te-fv te-ff te-ev te-ef)) + (to-expr-ex te-fv te-ff te-ev te-ef) + (from-expr-orig to-expr-orig)) (list (sys:expand-with-free-refs from-expr e ,awc.outer-env) (sys:expand-with-free-refs to-expr e - ,awc.outer-env)) - (sys:awk-code-move-check ,awc ',aws-sym form - (set-diff fe-ev fe-fv)) - (sys:awk-code-move-check ,awc ',aws-sym form - (set-diff te-ev te-fv)) + ,awc.outer-env) + (list (cadr form) (caddr form))) + (sys:awk-code-move-check ,awc ',aws-sym + form from-expr-orig + (set-diff fe-ev fe-fv) + 'variables) + (sys:awk-code-move-check ,awc ',aws-sym + form from-expr-orig + (set-diff fe-ef fe-ff) + 'functions) + (sys:awk-code-move-check ,awc ',aws-sym + form to-expr-orig + (set-diff te-ev te-fv) + 'variables) + (sys:awk-code-move-check ,awc ',aws-sym + form to-expr-orig + (set-diff te-ef te-ff) + 'functions) (push rng-temp (qref ,awc rng-expr-temps)) (push ^(placelet ((flag (vecref (qref ,',aws-sym rng-vec) ,ix))) (let* ((,flag-old flag) ,flag-new) |