From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 31140 invoked from network); 1 Sep 2021 16:03:23 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 1 Sep 2021 16:03:23 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1630512203; b=HbpLSw39GdK8wZxES9vOUYWPjTSPJWGMjLBN813/tsYybxba7U4iicoajMYBFia55iKd85CJ5U 02JdjFpA+MFcqdJnI5asszB4fTllZQvjylw2VnltF8DFbnR2P0bK8DdM5ptu0uL0XKgKPLUpGv OG0M5M3UOQeMX9yEJXXtXp+Nd9w5dt+RcG6Lrv36DkkpJw9C+G+4QOUUPSxhb28rCJ/3jCr4N7 fFKDxwJSYWiU4aShPzFGqiRRPFMUTzOkCv3jDx3p2dVJDqvfeaWNnqzshds+0zA6hCOzJoAfQm Qtprs4+NYAuFcYh+bFxfhP0Pp7Iua9Vp4xQo2fEcmCcfCg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-vs1-f49.google.com) smtp.remote-ip=209.85.217.49; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1630512203; bh=v71H9HpPan2pEo20qICL+vQ1LOFRdriZvhO9ACwpsSw=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:References: In-Reply-To:MIME-Version:DKIM-Signature:DKIM-Signature; b=rUxFd7z6OFdaQ0bAOVhh1c4vjW6F7z9vDP993NRz4zSMMXeWAROEjCbNH+ijm3kzayrU2N7NND 9ToLPJqMV+cg5dGkH8m7U3/E4iDHgwTqk/1rx/3s+AWfk0K2X3cwH4MTdjEDMTFAzwZ7r5HEjl rtR/puvZyzTn3RhhHEOx0PMZhdweT/Y67KFMxV7AhJ98qp10Kb/S9eVp9E9gMlQyHQxfiQZoFm 0gRolarsz4+Sd3vGMB7V5pTZ14T7/t6dJkZY0Xrheuvm3HyYl9/pp0JZiKV3ubi81z1STI7UFI 4Zsyut1OeMVinvEahI8oUL43asW/NJY4Q7JX4BswxmpRTg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:References:In-Reply-To:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=nhBc9tAKpN+IzimCMPRXauCKWn7MRpHtFEAdk5liBNI=; b=o2xe4XZGDgczZ1dZJQoF0e2qq9 Aoo7UuWPl24lKx6lLlltF2flC7uAMca254BLw6WLUA1U/vWFACMRWcA5M9bgsfe/q6Lq/6qbM+Cp7 2XVdfSndMh4jq8IQdyS4C3taqU5GcpLw2g6XOaPk+opI5SnjoMkI9JlRCH65d074wLf8ZkPCPAMny pTQ32KpcAVw3b52dN/Mg8DxEHXRKoZIRFCRM0PwRNTqFDW4DwTKkJq5ZP2BiW8pOw5FVtZozepb9v 71J6U40IdWagdnW/SnNfJph6n9PTBcBXSl84nxkfkALBYgLt9TLLlBCCVaGbuAdJyx9qNMhvlVvL6 WHnQEcHQ==; Received: from authenticated user by zero.zsh.org with local id 1mLShv-0003Fq-JD; Wed, 01 Sep 2021 16:03:23 +0000 Authentication-Results: zsh.org; iprev=pass (mail-vs1-f49.google.com) smtp.remote-ip=209.85.217.49; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-vs1-f49.google.com ([209.85.217.49]:39509) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mLShb-0002xL-5i; Wed, 01 Sep 2021 16:03:04 +0000 Received: by mail-vs1-f49.google.com with SMTP id m190so196815vsm.6 for ; Wed, 01 Sep 2021 09:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=nhBc9tAKpN+IzimCMPRXauCKWn7MRpHtFEAdk5liBNI=; b=jkt/EkqvOcH+hYYAzobE7D+hyzspeOn14ms/iXf9KyloR664Uos+6d3LfZm3Xb6V4J qQN3teEXExAd1dzy57uYxmLANlLXJ3A0UIRhXrZegeUwqly3XlY0CopDi4ZB+fa7yJtc OOlwOndS8pr4TfjhZ/CENTGR/NzFySD1aNHu0aUQY98lwUTwbq6utHhhYUKcHvStd6cp ZjxPtx+GveHX+mVIBGSUqUc8w7dMz3f0a07tr6w0KnDGqucUycgENb3aEVaFlDgnWwUx vI5rzs9YLSUYvUoF4OJm49NEN7WsXrhVjaCeCCmgJqykd+4bXBX0CvTzz+VX7Y7QV3SU Ostw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=nhBc9tAKpN+IzimCMPRXauCKWn7MRpHtFEAdk5liBNI=; b=MmpN4GnbMpczTIjvVhAttEg7of0sZcioFNM52ZRnc+bLSk3ULObiiPAaRZWZRWHW3W YZbOKLpIIfeyMb4hqwOfYR5zbkHuzx9PJv3rgDyzfAh6mYr7frmsMx1bhkKZwsqKMPJG /r+M/qoxRsgGE+p7GdpXXweOzwRa8Ds7qArcPx9k28A7G6zGD7dszFnuCfoBjOonmBpY AeKAecJzsL3Hel11PaWPI2SGI2plpCrbjQtt1TIuTBKF2C0ndM4KFUs/ZJ4k7aRh7dOD YzKHJrCsINVwubZPlB4+RiC+4UiFwcACjl2xFlwE784wCxPBzvZAbP3VemPrOJJAdhI1 cwXg== X-Gm-Message-State: AOAM531u2AuSVeZU6vFD/DOgDKdr4OT3hP92+SOhoFtxlPf4bpzSPyCM H1KPh/EzCsJn+LEjMjbCjHUqN7lANTo6ktWoMtQ= X-Google-Smtp-Source: ABdhPJyu2S8rWGFS01rUDbzFcEVq/bzgx/NnrREWzw9wpZgFotiKsaomJuNpRj3nwe8Usnl/k/NkD43ct/2HKQ2Dhlc= X-Received: by 2002:a67:fa88:: with SMTP id f8mr208398vsq.16.1630512182252; Wed, 01 Sep 2021 09:03:02 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab0:60b2:0:0:0:0:0 with HTTP; Wed, 1 Sep 2021 09:03:01 -0700 (PDT) In-Reply-To: References: From: Mikael Magnusson Date: Wed, 1 Sep 2021 18:03:01 +0200 Message-ID: Subject: Re: [BUG] zsh/param/private scoping error To: Bart Schaefer Cc: Marlon Richert , Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 49354 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On 9/1/21, Bart Schaefer wrote: > On Wed, Sep 1, 2021 at 4:51 AM Marlon Richert > wrote: >> >> % () { private tst; () { tst= } } >> (anon):1: tst: attempt to assign private in nested scope >> % >> >> This is not how one would expect private variables to behave. > > But it's how variable scoping behaves in the shell language. If I do > > % () { local tst; () { tst=foo } } > > Then it is the tst in the surrounding scope that gets altered, not the > global one. If the inner function is INTENDED to create a global, it > should be using "typeset -g" explicitly. This seems weird to me, since private is stated to be "used to create parameters whose scope is limited to the current function body, and not to other functions called by the current function." If the private parameter is not in scope, then any called functions should behave as if it is not in scope, ie automatically create a parameter scoped to whatever level is above the one that has the private. (technically speaking, this is probably hard). If private parameters are only compatible with code that runs without warnings under setopt WARN_CREATE_GLOBAL, then we should document this. -- Mikael Magnusson