From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 9DCFD29E66 for ; Sun, 4 Feb 2024 00:53:09 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1707004389; b=Y8LXOxxj+rPRbmLgreAcqPMTm83lPa6dz+1Qa/ypF+8u1WBq008Eahv4hVDapQ2dfI++iHN2u/ UraTBkTHeK6CITJA5L0CL6yS3oOreCSljnhePaoFmkmuvaS9/Jawg/dJDtlfMuhKoz8FrbUr99 N1wveoBqi4U7KBPfWuJiEIRkXURvEckuV+RSzUTc10WkQwss6zeXnbG0c+wukOrKmN3zfNqwv+ j1575fRe9e2acLY0YvTW7Lzo7XuI4/tiw8JmALnPJ8IIdf/5JNN2/R6+apRH2bHkH7s3kwnGRo aqIikzodXzmATcG0+h7vi+OGdoJMr30u0u6iLSjf0zpNWQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f48.google.com) smtp.remote-ip=209.85.218.48; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 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=1707004389; bh=kf9utMBcf8mBVQqX6mTC/ZFvuo0BHIvZVfy5VMF5M6I=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature:DKIM-Signature; b=sfLlonTzW34szHGybU6MEyozs5HGeRkUJFDwrVk/D+5NQ1yuj2FAUZOAPV2zsXFGR0csv+b0sA WOBKerTuLPBBvjua2ZsdSxeSrqBrPYGDaIaaj0KnYd/TlUkFwxLKe2TwjbD5i3wbx9gotOx+WO SgQbmq2ygDBX5WkVzeAykw2LCR5iRQjmDg59EL7FujDljPXqOCwsT6by+rerJtBAKGc2Q8icpk vqroIS8YrUKAlq3rbbdVxUDEXPX1PKycwkUSIaiyAVaTZXyi5ALMYgUMskJP/FXcPDkORkuTaT mhhKrcq5hWANDrhTkFi/1u/8RlNDmbepUKHiDEQgqlfR3Q==; 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-Transfer-Encoding: Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=huQOkWIrNz3nCaLszOTRe2obfKqUPE6m4HaanvgUuWI=; b=eIUzgpiW+ouDTqPiGJno01BK7a lsFbokeYjs0qFSW6yRqje+i3jCGQ6o+4Qntv2R+CZAgyS8ncP35sr1Rosw5ES8/A3oL8TQRwGwL5h 9iBeORHLu8gPN0yphxz/yVTfdLLaEaM7M3NvmVrLt4LPdNoloP0upuWRyPGbYs2jazSu/SryEZeq2 7IC1nLNg4YWSLQc6LE4dHo25nzGcJ6LXg7J2a1IvBcwwGOn4Jq4xPieP8Exrh54qL6mHOkau1jCGA rCIpOcBcblwCL+QHMI0ol9bNeXBfGtSWxr1MAvfvbj/I82TWyHr3kEFEV5bP7FQ7pAhdzDhYuda9F cbIpyneA==; Received: by zero.zsh.org with local id 1rWPor-0008ry-7h; Sat, 03 Feb 2024 23:53:09 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f48.google.com) smtp.remote-ip=209.85.218.48; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f48.google.com ([209.85.218.48]:50407) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rWPo4-00089o-D4; Sat, 03 Feb 2024 23:52:21 +0000 Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a350bfcc621so391553366b.0 for ; Sat, 03 Feb 2024 15:52:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1707004339; x=1707609139; darn=zsh.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=huQOkWIrNz3nCaLszOTRe2obfKqUPE6m4HaanvgUuWI=; b=jeSlz6HTI7qaaLVlcHzG9Qwbw3vev+VTETSIEi0TSgn9vP6RHoCNM30LmSFACVbS/3 jjiBS/4h+C6E+xNoK7BzOxnGOdNdf96k6grOuDO0qaBIlden30a3RCVXjUjbqAA0HFse LBj9fw2AtSQBmwDD0pgGAcCFNAAMjuVkEdIjXpUfGWmkFEcG84Hg/0o66AyXOdiktIys vjtdbLCsSnaF1YtlpbFHEu2Zf8VwEBzdB8uevxpqysgLmeoGq5eiryCmU/pEHaK+2N/X k841DxAZxS+FIs6TaegNUj5kRK5afKJVUeVodHdffJJ29GmCuB4pAy2E3BkqDvXCHIis yqtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707004339; x=1707609139; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=huQOkWIrNz3nCaLszOTRe2obfKqUPE6m4HaanvgUuWI=; b=hidP/yxApOCpznvt4ASZZQIstyL8V3IPtJPTguwOjshH5BRKYWjsTlJW+WtiFXRaE4 CTH/liuFpbOo+qu31C8R6u2mQ8YlBhpBQTCN3XWPDxZPFj2HgiifckY51skV25wFXIEr nNjcImsM6NsLIY8Ip9Aex8gTQXUvAtDy5skQOYJHNvyRFVLmrlHvdSH/X5nik4jN5E68 LH9oDbYizFvKygX4/2sdNKumkuuUF07VkzOjVTlVPf/oI/x+l1zSNZllxd/h+1bLlXc1 aJfLRctEth15kY23peJoRi8JCeF9A9zHxMz/xdMeAiZ5IamSZcTI2cIeyrm7EU1ahlac K+ew== X-Gm-Message-State: AOJu0YwHAlUi6CsSJjIUJ5cM2NXu5X2/CYuW2W+uOqlb0EaW6b0WwdFy pn6rLAFbCArPiYz6TcVIw1Ivm/5yDsVUDCtwOfbDDm2KpjLLRIm/ZWy+2KRA05KUvlhtYrQty/9 VM+o1TURKkXmTkxx4sHvSYu820g91vQXpkht9y47t3dcpRSU= X-Google-Smtp-Source: AGHT+IGi5b1dKlcIREiJtXxkhr5bXfZY9txD2z+EzUAmbBZ1hKt0xVv3LflfjpzbHxzRF8i+NW46REYHFdJw3gQknJo= X-Received: by 2002:a17:907:77d3:b0:a37:1906:1173 with SMTP id kz19-20020a17090777d300b00a3719061173mr3090338ejc.34.1707004339609; Sat, 03 Feb 2024 15:52:19 -0800 (PST) MIME-Version: 1.0 References: <4c14e191-0605-4492-9f67-9a5b35ef132b@eastlink.ca> <4da0eeb4-4589-4c5d-9b89-a1a22209e18e@eastlink.ca> <7ccf5b82-a37d-47b5-a700-fb1096ab495c@eastlink.ca> <0875ffd7-e3a4-4ddc-9c4b-47e2c593ea4c@eastlink.ca> In-Reply-To: <0875ffd7-e3a4-4ddc-9c4b-47e2c593ea4c@eastlink.ca> From: Bart Schaefer Date: Sat, 3 Feb 2024 15:52:08 -0800 Message-ID: Subject: Re: for loop 'bad math expression' To: zsh-users@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 29619 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Tue, Jan 30, 2024 at 5:44=E2=80=AFAM Ray Andrews wrote: > > BTW Bart, just a post mortem on that: I know there are situations where > a plain vanilla scalar is promoted to integer As Lawrence also suggested, I don't believe that happens. If a parameter is created inside a math expression it will be assigned an appropriate numeric type, but the type of an existing scalar is not changed. Note "created" here includes the case where the parameter was declared but later unset and then assigned again in math context. Parameters may also be converted to and from arrays by assignment, and that includes converting from an array to a numeric type when assigned in math context. Maybe that's what you're thinking of. > I wonder about an automatic demotion. The > situation plainly had nothing to do with arithmetic Context-awareness doesn't extend that far. Globbing is already done and gone by the time "for" assigns its loop variable, nothing tells "for" where the loop values came from, and shell words on a command line carry no type information. > perhaps automatic 'non demotion' would be possible -- zsh might have > robust defenses against making a mistake. You might try setopt warn_create_global to detect cases of names "leaking".