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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 9147 invoked from network); 1 Sep 2021 17:36:52 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 1 Sep 2021 17:36:52 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1630517812; b=eSuQboG37tOKZbGaByzgJbobLsz39ayQVdU41xFxikbWGbPPH2HNZOV1zaWa5Orx/Yo9qD/cyB slUX+GsALEhjdzl1PI8cHeHQGmCK+fJ3ef9IPUDaA+I73NBUMG+7XxSJVX0//H2c61gL/NWBkR eW/sq3YOpLwhr+uDgzjeW03hWbO93RbWgBZ7cZjYR1sPoBv04Gl6NEuQOKN/u3f9MO5UxOOfYJ tErwFKCK6J4aSItcWdo19qikDVXQbephUCoqT3yDJ3GmjHfNt9o86Q6b/Viur3EU1S33YM+RXE CLgyLSzbC92XsZpcTj1RCt9W5rVE5MH5oEvPs3fl3qGEIw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-yb1-f180.google.com) smtp.remote-ip=209.85.219.180; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1630517812; bh=aAAUmFT50ObvCfOqYHndpUSYPXy3P+SFTg/kuhjDJyY=; 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:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=SOL9jMB9zuPW2VMgBO7NM8g1ULzj6V61DtGFHh/zyCUFN0SRkGYYcGnFOaIVQD2hY4WG5ppj4i 15GXowZz2qCNluzpGNIDjVHuRLIqtiDKt3ixbUsvDuCjs8ep2hWli3RKIcBlc3VldXFX64+Wqv BWcBD3lHCrdrK2ypCFtdYapDbxvzKGcmEUnKCNEXYFx0Vn+kivkHJtrFCyncb0ARy7K3Ixht9q ClK9giavsWixRDVBEP61SlZU3gSCdLmAc2MBQ2jp1Ez3KyBCOSXvZkNUFXn9YWeSq3xHGJfCqi aw5MqO7DhYPO70mVpmZR7IVSjN8DEZxsrh3/QxK0W57N1A==; 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:In-Reply-To:References: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=dvePwY/ztYi//0XlUvvqFw+w5oGtuz5TxyV8cAxs1E8=; b=gD0MhO12xmn5qF+MyeBeiz1/8e +3+V4bN7aJQmzCrIdVSy2FVVN2VfzASJj8QRp9DOVMsh4LpMW8ae/+lmdc1Vuv3PBmP/0N4HZYbNU ao+o5/8nqEmmNb+jiWTtLSBIt79xf1ipZ76L3w0SweL4wKG0cq/ndq6TrtIGE8RuD1NEP0AWSl46U 8uZWXk8tRVoYCpE5ZVVrYxPjXPQYXA4szixXOF1jyitiWfaZLNRnqoQxP2u7eP8T+pTgceP5knOlS QZTx+7pb4yOG0EfLPXN2uahL8px9lovxYgiyQp6q6rApLCGczWWSDfE6SnKUR/ftMamG5TjeSlmTQ Bg/DNNCg==; Received: from authenticated user by zero.zsh.org with local id 1mLUAO-000AfI-83; Wed, 01 Sep 2021 17:36:52 +0000 Authentication-Results: zsh.org; iprev=pass (mail-yb1-f180.google.com) smtp.remote-ip=209.85.219.180; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-yb1-f180.google.com ([209.85.219.180]:44951) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mLU9j-000ANU-12; Wed, 01 Sep 2021 17:36:21 +0000 Received: by mail-yb1-f180.google.com with SMTP id q70so68959ybg.11 for ; Wed, 01 Sep 2021 10:36:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dvePwY/ztYi//0XlUvvqFw+w5oGtuz5TxyV8cAxs1E8=; b=lMiVa20HzH9vvU3kgiN+a/1fWclrjIdrPFNtluuJMYNN/LfrrIa2FJvgEVkpMGeGmt QWr6/UV/g9bIK1LRBKyBQse0JIRZRwQORoYirHTYeuJ8wTcZ8iBiGi1vJO3j/c3WaHNc NjNHqljO6+fkjRZcESrZBBvz8hplGMR6c1BEjH6Oe9OHQgisFL1EXiikfkCEL/Le+NYt FTLTCQnzGVjn5VwSpqx6+UOrH5AMm7o1dkZBuxd7Y6Tlc40jMR0XvbC1+spq8yWv9DuA qyDbDbOqv7eXmC5WxwBHHvdL/sV1tJDTf8sBLmUTDa/TJjJFXGH89rpXDobvHEt5botC VPoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dvePwY/ztYi//0XlUvvqFw+w5oGtuz5TxyV8cAxs1E8=; b=plHPR/kBLY0jjetDVI4tCPBT/D5NtM5LqYI/PBtxgeYB0+Jko2BwFLCaDzKuhLOaUJ D6dbxPi/W06IQvY2g15S1uuqY9tYXUCysyG0Bo59PdYEAxgM2E5L/lR1LO2WfUAMftYZ o0bJu4hE+Zva+uaDxaU969YKsiU/G1FFRnJxtfSgHKQfqhKpOM7wp+kkYUZlPFYUDWKQ GE/Fj7uAMeSYfdE9bYMlc3R+IeqoOwTM9gI/02t6nPadAE0BKIeROzrBwVBzC6cJK259 65D3keLG6mk7v+H7HPfgje837JpfpDK+7SAJ3yyGEIlyB0Qm3kouIVQoPt8AP7Xq1kw7 98MA== X-Gm-Message-State: AOAM531wiaVwVomYrDVdgk6iLw8QcllKFL+synrOgkHRDDKZ/RNWWrxB nOvlGTJjoQw/IfQPCTuXwVQnLp013lHNxP0BJCEiaw== X-Google-Smtp-Source: ABdhPJzRhAIzLQMWgM30FcNf8+ma3rFdwU4qifRiNTCm0of1RTUERX4063jrSHXKqg7GdqQzcDx2Ff7nY/Ojnfe7nn8= X-Received: by 2002:a25:d8d2:: with SMTP id p201mr903467ybg.69.1630517769972; Wed, 01 Sep 2021 10:36:09 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Wed, 1 Sep 2021 10:35:59 -0700 Message-ID: Subject: Re: [BUG] zsh/param/private scoping error To: Mikael Magnusson Cc: Marlon Richert , Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 49358 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 Wed, Sep 1, 2021 at 10:00 AM Mikael Magnusson wrote: > > Ah, I misinterpreted one of the examples, I thought that this would > work as you expect: > () { private foo; () { typeset -g foo=bar } } > (while this wouldn't: > () { private foo; () { foo=bar } } > ) > > But in both cases it is an error (although only the latter prints a > message and aborts execution), and foo is not set globally. Something else has changed since the implementation of private, I think, because this is not what I expected: top () { private foo=top; mid } mid () { typeset -g foo=middle; bot } bot () { print $foo } functions -t top % top +top:0> private foo=top +top:0> mid +mid:0> typeset -g foo=middle +mid:0> bot bot: foo: attempt to assign private in nested scope What makes the expansion of $foo in bot into an assignment? > In fact a typeset -g is needed on the global level before the function > using private is called, which seems impossible for the innermost > function to enforce. As you can see from the "F:" test Marlon quoted, this is something I eventually intended to change. It's rather complicated because of the way locals are implemented as a LIFO at each individual named entry in the parameter table, rather than a LIFO of parameter tables. Even without private, "typeset -g" only reaches as far upwards as the most recent local declaration of the name.