On 2024-02-04 06:43, Mark J. Reed wrote:

That's not qutie what's happening. Arithmetic expressions interpret all variables as numbers, whether the variables are declared as integers or not. If a variable's value doesn't look like a number, it is interpreted as the name of another variable, which is then looked up recursively. If it gets to a variable that doesn't exist, the value is taken as 0.
I get that.  $(( abc ..... )) ... abc isn't a number therefore it's the name of a variable.  However I did:

% var=abc
... outside any (()) and the conversion happened 'retroactively' so to speak.

% var=path; print -- $var
path
... 'path' is just a string, there's no implicit conversion to a variable.  Ergo:

%var=abc
... seems to me the same.  Later on abc becomes an integer name, and the string is lost

... it will be converted back to a string that just happens to be all digits. What's the difference? Well, let's continue your example:

zsh% var=abc; let var+=2; echo $var
2
zsh% var+=2; echo $var # note: no let
22
Right, I get that too.  A string of digits is still a string. 

Anyway it goes back to my original speculation/question that implicit promotions/conversions do happen thus a 'demotion' -- in the case of that glob expansion -- is something that might at least be contemplated even if in fact the idea is unsound.  As for me I think that taking a string and then using it as the name of an integer is a bit strange, but it is what it is and I won't crash into that problem again.