view test/bug-53027/ntest53027b.m @ 24977:2b040946dc69 stable

improve handling of clear for globals, forwarded symbols (bug #53027) * symrec.h (symbol_record::symbol_record_rep::clear): Don't return early after unbinding global. Don't check for forwarded symbol here. * symrec.h (symbol_record::is_forwarded, symbol_record::symbol_record_rep::is_forwarded): New functions. * symscope.h (symbol_scope_rep::refresh): Don't delete forwarded symbols. * test/bug-53027/bug-53027.tst, test/bug-53027/module.mk, test/bug-53027/ntest53027a.m, test/bug-53027/ntest53027b.m: New test files. * test/module.mk: Include test/bug-53027/module.mk.
author John W. Eaton <jwe@octave.org>
date Thu, 22 Mar 2018 17:34:41 -0400
parents
children c16ad80274c9
line wrap: on
line source

function [m_exist, n_exist] = ntest53027b ()
  global x
  x = 3;
  n_exist = nest ();
  m_exist = exist ("x", 'var');
  function n_exist = nest ()
    ## The clear statement should operate on the variable in the
    ## parent scope even though there is no explicit varabiable
    ## reference in teh code (the clear function just sees a string
    ## containing the name of the variable and the parser (correctly)
    ## does not treat this as a special case.
    clear x
    n_exist = exist ("x", "var");
  endfunction
endfunction