Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Ross Goldberg Newsgroups: gnu.bash.bug Subject: Cannot shadow local -r when assigning local to array in declaration Date: Thu, 23 Apr 2020 20:02:18 -0400 Lines: 59 Approved: bug-bash@gnu.org Message-ID: References: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: usenet.stanford.edu 1587687696 28884 209.51.188.17 (24 Apr 2020 00:21:36 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=4dD+Om8Yx7pJAjL74GX9Ne5rKD7h8dcZExDZDFV3fmY=; b=KlpfR+P1DeMmPCSpnWfYFEzfGniOZ4qqH1EWC3jZsQ1aYsHgM6wf9zeudPKdfzBGyB qcLLvp3Ll9wkFzb+Z/KuJe5mFeUTcSUhlIFxQW7q4d8ZX3nYH9lgkN1mxoz7BWBLZBIn 2k1wHK1CMiPEYXjA1/vuO+1QBqLnTDxruZAUHyVoL7JprLFG/KklP/T1gKV0CWlnT1zx Svb6hxgqis3e+Y40FPpqK/V3zraIe0jOtWnYnf1OpncgFs3hOYVplCd1VsZKzSNpyQWD Yf1FlhTbEFvRLfhSEY0j6Nkm17tGK92f7G6pz4SS1qtzEf48JJAbYuZszU8MVTpInckm dWVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=4dD+Om8Yx7pJAjL74GX9Ne5rKD7h8dcZExDZDFV3fmY=; b=l5Z2XIyEJHE+fzRV45sGD2Q0PTEI7FnLX/fcAa21MtbEWdv0fNWF/Adp4ViudT4Rte KDc/7U1DUS+WALmvNvejx6eLUUJoT4D86CVl7ec+JD/LhUWg136vR5yRcvKMj8XSAgs+ nDmYdkVBytrlExOIcR/R+GOGrnePvWYHDRorB2KdhRsOydR3urGSuj5jP/iZbbo73KVb fKsJ8tvPOFBUKEnpfs/mEOdUvbT4uht7vGDxQCjs4ifg9BfP6hVyAZgt9Pc5IQSnxYeY o3p0Wtd3mlRRmozQz4LYqIMATOpIAaLLCH4nbOzjr6dJqAMTubQybonUG9pN1l2wzwnD ZY6w== X-Gm-Message-State: AGi0PuZsNPk/hNGF7boG4oRKlZIywtMmujXoKW56QeRxxRud7rl+YSog aQ7y4ktkK/CuX/nK+WavSu9RhT1sEqGKZv1wpttR5Ba8xHs= X-Google-Smtp-Source: APiQypKTxRAbDVzjkNEHxpmYYj7vlWE4NItWWkGsTfuoJoC8ma0wBElMa4J6GFeivRCFJFc+garf8FF2kaodQPnK2b0= X-Received: by 2002:a25:ed06:: with SMTP id k6mr11331785ybh.57.1587686549193; Thu, 23 Apr 2020 17:02:29 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::b2c; envelope-from=ross.goldberg@gmail.com; helo=mail-yb1-xb2c.google.com X-detected-operating-system: by eggs.gnu.org: Error: [-] PROGRAM ABORT : Malformed IPv6 address (bad octet value). Location : parse_addr6(), p0f-client.c:67 X-Received-From: 2607:f8b0:4864:20::b2c X-Mailman-Approved-At: Thu, 23 Apr 2020 20:21:34 -0400 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: Xref: csiph.com gnu.bash.bug:16235 Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: darwin19.3.0 Compiler: clang Compilation CFLAGS: -DSSH_SOURCE_BASHRC -Wno-parentheses -Wno-format-security uname output: Darwin Thrawn.local 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64 Machine Type: x86_64-apple-darwin19.3.0 Bash Version: 5.0 Patch Level: 16 Release Status: release Description: If a function, f, declares a local readonly variable, v, using local -r, an error occurs if f calls another function, g, that declares its own local variable v (therefore shadowing v from f) and that assigns v to an array in the same statement as the shadowing declaration. g can, however, assign v to a scalar in a shadowing declaration. g can also assign a shadowing v to an array, as long as it isn't assigned in the same statement as the declaration. Repeat-By: function aaa() { local x='1 2 3' echo "aaa ${x}" } function bbb() { local x x=(4 5 6) echo "bbb ${x[*]}" } function ccc() { local x=(7 8 9) echo "ccc ${x[*]}" } function ddd() { local -r x='0' echo "ddd ${x}" aaa bbb ccc } ddd # the above outputs the following: ddd 0 aaa 1 2 3 bbb 4 5 6 bash: x: readonly variable