bugGNU Octave - Bugs: bug #54423, Declaring a variable global erases...

 
 

bug #54423: Declaring a variable global erases its value in Octave but not in Matlab

Submitter:  Arnaud Delorme <arnodelorme>
Submitted:  Wed 01 Aug 2018 09:02:25 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.4.0 Operating System:  * Mac OS
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 01 Aug 2018 11:06:45 PM UTC, comment #2: 

For good measure, I checked in a changeset here https://hg.savannah.gnu.org/hgweb/octave/rev/337c944a9ac9 that makes the backtrace look pretty.

Rik <rik5>
Group administrator
Wed 01 Aug 2018 10:55:47 PM UTC, comment #1: 

This has already been changed for the 4.4.1 bug fix release.


octave:3> version
ans = 4.4.1-rc2
octave:4> testglobal
a =

   1   2   3

warning: global: 'a' is defined in the current scope
warning: called from
    testglobal at line 5 column 1
warning: global: in a future version, global variables must be declared before use
warning: called from
    testglobal at line 5 column 1
warning: global: existing local value used to initialize global variable
warning: called from
    testglobal at line 5 column 1
a =

   1   2   3


The reporting is a little verbose because "backtrace" is turned on for every single line, but nevertheless the behavior is the same.

Marking as fixed and closing report.

Rik <rik5>
Group administrator
Wed 01 Aug 2018 09:02:25 PM UTC, original submission:  

function testglobal()

    evalin('base', 'a = [1:3];');
    evalin('base','a');
    evalin('base','global a');
    evalin('base','a');
   
Running the function above in Matlab 2018a

testglobal

a =

     1     2     3

Warning: The value of local variables may have been changed to match the globals.  Future versions of MATLAB will require that you declare a variable to
be global before you use that variable.

> In testglobal (line 5)


a =

     1     2     3

Running the function above in Octave 4.4.0

testglobal
a =

         1         2         3

a = []


Arnaud Delorme <arnodelorme>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by arnodelorme (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-08-01 rik5 StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code