# HG changeset patch # User John W. Eaton # Date 1444603985 14400 # Node ID f9c991dc5c1a6d93085719bff5cd8ba3f9a4c315 # Parent a260a6acb70f12a95a0f7e575ce724caa16cd14f avoid scope error in anonymous functions (bug #45835) * ov-fcn-handle.cc (octave_fcn_binder::maybe_binder): Don't optimize functions that wrap eval or feval. diff -r a260a6acb70f -r f9c991dc5c1a libinterp/octave-value/ov-fcn-handle.cc --- a/libinterp/octave-value/ov-fcn-handle.cc Sun Oct 11 23:09:01 2015 +0200 +++ b/libinterp/octave-value/ov-fcn-handle.cc Sun Oct 11 18:53:05 2015 -0400 @@ -2066,29 +2066,32 @@ { // It's a name. std::string head_name = head_id->name (); - // Function handles can't handle legacy dispatch, so - // we make sure it's not defined. - if (symbol_table::get_dispatch (head_name).size () > 0) + + if (head_name == "eval" || head_name == "feval") bad = true; else { - // Simulate try/catch. - unwind_protect frame; - interpreter_try (frame); + // Function handles can't handle legacy + // dispatch, so we make sure it's not + // defined. - bool execution_error = false; - - try + if (symbol_table::get_dispatch (head_name).size () > 0) + bad = true; + else { - root_val = make_fcn_handle (head_name); + // Simulate try/catch. + unwind_protect frame; + interpreter_try (frame); + + try + { + root_val = make_fcn_handle (head_name); + } + catch (const octave_execution_exception&) + { + bad = true; + } } - catch (const octave_execution_exception&) - { - execution_error = true; - } - - if (execution_error) - bad = true; } } } @@ -2113,6 +2116,12 @@ return retval; } +/* +%!test +%! f = @(t) eval ('2*t'); +%! assert (f (21), 42); +*/ + octave_value_list octave_fcn_binder::do_multi_index_op (int nargout, const octave_value_list& args)