Mercurial > jwe > octave
changeset 29349:0998695317d8
maint: merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 02 Feb 2021 16:40:33 -0500 |
parents | b50ca5cbfb0f (current diff) 4de13dc0eff2 (diff) |
children | 8f0d0d4690c0 |
files | test/nest/nest.tst |
diffstat | 4 files changed, 25 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-fcn-handle.cc Mon Feb 01 10:01:59 2021 -0800 +++ b/libinterp/parse-tree/pt-fcn-handle.cc Tue Feb 02 16:40:33 2021 -0500 @@ -156,6 +156,16 @@ // FIXME: maybe it would be better to just stash curr_fcn // instead of individual bits of info about it? + // An anonymous function defined inside another nested function + // or parent of a nested function also behaves like a nested + // function. + + if (curr_fcn->is_parent_function () || curr_fcn->is_nested_function ()) + { + af->mark_as_nested_function (); + new_scope.set_nesting_depth (parent_scope.nesting_depth () + 1); + } + af->stash_parent_fcn_name (curr_fcn->name ()); af->stash_dir_name (curr_fcn->dir_name ());
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/nest/bug_59989.m Tue Feb 02 16:40:33 2021 -0500 @@ -0,0 +1,12 @@ +function y = bug_59989 () + unpacker = @(x) sum (x); + function y = nest1 (x, a) + y = a + unpacker (x); + endfunction + function y = nest2 (fh) + x = [2, 3]; + y = fh (x); + endfunction + a = 1; + y = nest2 (@(x) nest1 (x, a)); +endfunction