# HG changeset patch # User John W. Eaton # Date 1523419626 14400 # Node ID 72ea868ca63afafa0d5fe2f77d8a57f8a56643e4 # Parent d12271fe1504ce5d084d0c52d037918e2031582b allow function parameters to be global (bug #53579) * symrec.h (symbol_record::unbind_global_rep): New function. * symscope.h (symbol_scope::refresh): Use it to also unbind global symbols. * test/bug-53579.tst: New file. * test/module.mk: Update. diff -r d12271fe1504 -r 72ea868ca63a libinterp/corefcn/symrec.h --- a/libinterp/corefcn/symrec.h Tue Apr 10 23:58:10 2018 -0400 +++ b/libinterp/corefcn/symrec.h Wed Apr 11 00:07:06 2018 -0400 @@ -686,6 +686,8 @@ m_rep->bind_fwd_rep (fwd_scope, sr.m_rep); } + void unbind_global_rep (void) { m_rep->unbind_global_rep (); } + void unbind_fwd_rep (void) { m_rep->unbind_fwd_rep (); } octave_value dump (context_id context) const diff -r d12271fe1504 -r 72ea868ca63a libinterp/corefcn/symscope.h --- a/libinterp/corefcn/symscope.h Tue Apr 10 23:58:10 2018 -0400 +++ b/libinterp/corefcn/symscope.h Wed Apr 11 00:07:06 2018 -0400 @@ -277,7 +277,9 @@ { symbol_record& sr = nm_sr.second; - if (! (sr.is_persistent () || sr.is_forwarded ())) + if (sr.is_global ()) + sr.unbind_global_rep (); + else if (! (sr.is_persistent () || sr.is_forwarded ())) sr.clear (m_context); } } diff -r d12271fe1504 -r 72ea868ca63a test/bug-53579.tst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/bug-53579.tst Wed Apr 11 00:07:06 2018 -0400 @@ -0,0 +1,21 @@ +%!function [raa, rbb, igaa, igbb] = sub1 (aa, bb) +%! global aa bb +%! aa = 1; +%! raa = aa; +%! rbb = bb; +%! igaa = isglobal ("aa"); +%! igbb = isglobal ("bb"); +%!endfunction + +%!test <*53579> +%! global aa bb +%! assert (isglobal ("aa")); +%! assert (isglobal ("bb")); +%! aa = 3; +%! xx = 5; +%! [raa, rbb, igaa, igbb] = sub1 (aa, xx); +%! assert (raa, 1); +%! assert (rbb, []); +%! assert (igaa); +%! assert (igbb); +%! assert (xx, 5); diff -r d12271fe1504 -r 72ea868ca63a test/module.mk --- a/test/module.mk Tue Apr 10 23:58:10 2018 -0400 +++ b/test/module.mk Wed Apr 11 00:07:06 2018 -0400 @@ -12,6 +12,7 @@ %reldir%/bug-38576.tst \ %reldir%/bug-46330.tst \ %reldir%/bug-49904.tst \ + %reldir%/bug-53579.tst \ %reldir%/bug-53599.tst \ %reldir%/colormaps.tst \ %reldir%/command.tst \