1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-12-29 16:25:35 +01:00

37489, tweaked: with POSIX_IDENTIFIERS create math var as scalar

This commit is contained in:
Peter Stephenson 2016-01-03 18:57:10 +00:00
parent 63c6d1746c
commit 524f802610
3 changed files with 18 additions and 0 deletions

View file

@ -2098,6 +2098,12 @@ When it is unset, zsh allows expressions of the form tt($#)var(name)
to refer to the length of tt($)var(name), even for special variables,
for example in expressions such as tt($#-) and tt($#*).
Another difference is that with the option set assignment to an
unset variable in arithmetic context causes the variable to be created
as a scalar rather than a numeric type. So after `tt(unset t; (( t = 3
)))'. without tt(POSIX_IDENTIFIERS) set tt(t) has integer type, while with
it set it has scalar type.
When the option is unset and multibyte character support is enabled (i.e. it
is compiled in and the option tt(MULTIBYTE) is set), then additionally any
alphanumeric characters in the local character set may be used in

View file

@ -3061,6 +3061,7 @@ setnparam(char *s, mnumber val)
if (ss)
*ss = '\0';
pm = createparam(t, ss ? PM_ARRAY :
isset(POSIXIDENTIFIERS) ? PM_SCALAR :
(val.type & MN_INTEGER) ? PM_INTEGER : PM_FFLOAT);
if (!pm)
pm = (Param) paramtab->getnode(paramtab, t);

View file

@ -409,3 +409,14 @@
>2
>(eval):6: bad math expression: unexpected ')'
>(eval):7: bad math expression: unexpected ')'
unset number
(( number = 3 ))
print ${(t)number}
unset number
(setopt posix_identifiers
(( number = 3 ))
print ${(t)number})
0:type of variable when created in arithmetic context
>integer
>scalar