rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

global and local name mismatch for tables in blocks #1101

Open rtoy opened 4 months ago

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-04 00:06:49 Created by ygorra33 on 2012-12-17 09:08:44 Original: https://sourceforge.net/p/maxima/bugs/2519


/* the following code produce a bug,when calling buggy(b)
because of a mismatch between the names 
1- of the global table a 
2- of the local function input a, when calling 
*/
kill(all)$
/* function definition */ 
buggy(a):=block(
  [],
  a[1,1]:0
)$
/* global a[1] declaration */
a[1]:25;
b:matrix([1,2])$
/* call buggy with b */
buggy(b)$
/* added to report the bug */
bug_report();
/*----------------------------------
MAXIMA OUTPUT
----------------------------------*/
Array a has dimension 1; it was called by a[1,1]
#0: buggy(a=matrix([1,2]))
 -- an error. To debug this try: debugmode(true);

/*----------------------------------
bug_report OUTPUT
----------------------------------*/

The Maxima bug database is available at
    http://sourceforge.net/tracker/?atid=104933&group_id=4933&func=browse
Submit bug reports by following the 'Add new' link on that page.
Please include the following information with your bug report:
-------------------------------------------------------------

Maxima version: 5.20.1
Maxima build date: 8:48 2/16/2010
Host type: i686-pc-linux-gnu
Lisp implementation type: GNU Common Lisp (GCL)
Lisp implementation version: GCL 2.6.7

-------------------------------------------------------------
The above information is also reported by the function 'build_info'.

Attachments:

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-04 00:06:51 Created by macrakis on 2022-09-23 16:23:26 Original: https://sourceforge.net/p/maxima/bugs/2519/#3732


As Robert says, the global array takes precedence over the value of a. This is as designed, so not a bug. But a bad design!

Here are two workarounds which force the use of the value of a rather than its array property:

unbug1(a):=block([], (0,a)[1,1]:0)$ unbug2(a):=block([aval: a], aval[1,1]:0);

Closing as working as designed.

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-04 00:06:54 Created by macrakis on 2022-09-23 16:23:47 Original: https://sourceforge.net/p/maxima/bugs/2519/#d578