bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Regression with declare -i and arrays


From: Eduardo A . Bustamante López
Subject: Regression with declare -i and arrays
Date: Fri, 3 Apr 2015 18:40:25 -0600
User-agent: Mutt/1.5.23 (2014-03-12)

Hello Chet,

You introduced a regression:

address@hidden /tmp/tmp.ps6HXrLSZX/devel-]$ ./bash -c 'typeset -i x; 
x=([0]=1+1); echo "$x"'
1+1

vs

address@hidden ~ % bash -c 'typeset -i x; x=([0]=1+1); echo "$x"' 
2

The regression was introduced here: 06c3a57511953d09ac9ea262bc18bfdbcff23fc4

The patch that causes it:

diff --git a/builtins/declare.def b/builtins/declare.def
index 69c4703..5ed83a0 100644
--- a/builtins/declare.def
+++ b/builtins/declare.def
@@ -506,13 +506,13 @@ declare_internal (list, local_var)
        if (flags_on & att_assoc)
    {
      var = make_new_assoc_variable (name);
-     if (offset == 0 && no_invisible_vars == 0)
+     if (var && offset == 0 && no_invisible_vars == 0)
        VSETATTR (var, att_invisible);
    }
        else if ((flags_on & att_array) || making_array_special)
    {
      var = make_new_array_variable (name);
-     if (offset == 0 && no_invisible_vars == 0)
+     if (var && offset == 0 && no_invisible_vars == 0)
        VSETATTR (var, att_invisible);
    }
        else
@@ -522,9 +522,11 @@ declare_internal (list, local_var)
        else
    {
      var = mkglobal ? bind_global_variable (name, (char *)NULL, 0) : 
bind_variable (name, (char *)NULL, 0);
-     if (no_invisible_vars == 0)
+     if (var && no_invisible_vars == 0)
        VSETATTR (var, att_invisible);
    }
+       if (var == 0)
+   NEXT_VARIABLE ();
      }
    /* Can't take an existing array variable and make it a nameref */
    else if ((array_p (var) || assoc_p (var)) && (flags_on & att_nameref))


Thanks to Geir, because he split the commits into logical commits and I was 
able to find this faster with git bisect.

I caught it by running: make tests

-- 
Eduardo Bustamante
https://dualbus.me/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]