bugGNU Octave - Bugs: bug #53579, Change in global handling for...

 
 

bug #53579: Change in global handling for variable in global and passed as argument

Submitter:  Michael Godfrey <godfrey>
Submitted:  Sat 07 Apr 2018 03:21:27 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  7 - High Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  godfrey Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 11 Apr 2018 05:25:06 AM UTC, comment #3: 

Works for me. Both stable and dev.
Thanks.

Michael Godfrey <godfrey>
Group Member
Wed 11 Apr 2018 04:30:10 AM UTC, comment #2: 

I pushed the following changeset, including a test:

http://hg.savannah.gnu.org/hgweb/octave/rev/72ea868ca63a

Please let me know whether the new test is correct.

John W. Eaton <jwe>
Group administrator
Sat 07 Apr 2018 07:06:43 PM UTC, comment #1: 

The new behavior is in the current stable 4.3.0+ version.
This means that the new release is incompatible with
the current 4.2.2 and with Matlab.

It may be confusing for users of the new release to just
report: "error: 'aa' undefined near line 5 column 3..."
where previously the variable was still defined.

It might be best to detect this case (variable in global
list and passed as argument) and report it as a warning.
This choice is compatible with the current Matlab
which behaves like 4.2.2, but also produces a confusing
diagnostic.

Michael Godfrey <godfrey>
Group Member
Sat 07 Apr 2018 03:21:27 AM UTC, original submission:  

It would seem that the handling of the case below in the
current dev is appropriate, but it conflicts with 4.2.2 and
previous versions. The error occurs if a variable in declared
global and used in a function argument list. Below shows
Matlab, 4.2.2, ad dev results. I do not fully understand
the Matlab error message...

I think that the handling in dev is a good choice, but the
error message should be made clearer and the incompatibility
with previous Octaves should be noted. The diagnostic could
be: passing a variable which is declared global as an argument
is not allowed...


The script top.m is:
global aa bb
  xx =1 ;
  aa = 1;
  sub1(aa, xx);
  aa
==================
sub1.m is:
function sub1 (aa, bb)
  global aa bb
  aa = 1;
return

Results for Matlab, 4.2.2, and dev 4.5.0+ are:

                                      < M A T L A B (R) >
                            Copyright 1984-2017 The MathWorks, Inc.
                             R2017b (9.3.0.713579) 64-bit (glnxa64)
                                       September 14, 2017


To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.

>> ls
sub1.m        top.m

>> top
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 sub1 (line 2)
  In top (line 4)
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 sub1 (line 2)
  In top (line 4)

aa =

     1

Results for
GNU Octave, version 4.2.2
Copyright (C) 2018 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "x86_64-redhat-linux-gnu".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/get-involved.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

octave:1> top
aa =  1
octave:2> quit

Results for dev:
[godfrey@pbdsl4 global_change]$ oct
octave:1> version
ans = 4.5.0+
octave:2> top
error: 'aa' undefined near line 5 column 3
error: called from
    top at line 5 column 3
octave:2>


Michael Godfrey <godfrey>
Group Member

 

(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 jwe (Posted a comment)
  • -email is unavailable- added by godfrey (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-04-11 jwe StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2018-04-11 jwe StatusNone Ready For Test
    2018-04-07 godfrey Priority5 - Normal 7 - High

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code