diff --git a/libinterp/parse-tree/pt-fcn-handle.cc b/libinterp/parse-tree/pt-fcn-handle.cc --- a/libinterp/parse-tree/pt-fcn-handle.cc +++ b/libinterp/parse-tree/pt-fcn-handle.cc @@ -120,6 +120,9 @@ namespace octave new_scope.set_parent (parent_scope); new_scope.set_primary_parent (parent_scope); + // FIXME: Do we need to install the new anonymous function as a + // nested function in parent_scope? See base_parser::finish_function. + if (m_expression) { tree_expression *expr_dup = m_expression->dup (new_scope); @@ -156,6 +159,12 @@ namespace octave // 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 function also + // behaves like a nested function. + + af->mark_as_nested_function (); + new_scope.set_nesting_depth (parent_scope.nesting_depth ()); + af->stash_parent_fcn_name (curr_fcn->name ()); af->stash_dir_name (curr_fcn->dir_name ());