zsh-workers
 help / color / mirror / code / Atom feed
* Numbers with leading _
@ 2022-11-21 16:22 Mikael Magnusson
  2022-11-21 16:27 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Mikael Magnusson @ 2022-11-21 16:22 UTC (permalink / raw)
  To: zsh-workers

I was playing with extending hasbraces+xpandbraces to allow _ in
numbers via zstrtoul_underscore, and noticed that in normal math
context, this happens:
% echo $(( _1000 ))
0
% a=(1 2 3); echo $a[_1]

% a=(1 2 3); echo $a[1_]
1

but my modifications worked fine:
% echo {_999_.._1_0_0_1_}
999 1000 1001

Obviously there's no real reason why anyone should want to specify a
number with a leading underscore but is there a reason to reject it in
the normal math context, and should we print some kind of error when
we do it rather than silently parse it as a 0?

I didn't yet try to track down where this rejection happens, but it's
at least not in zstrtoul_underscore.

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-22  5:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-21 16:22 Numbers with leading _ Mikael Magnusson
2022-11-21 16:27 ` Peter Stephenson
2022-11-22  5:07   ` Mikael Magnusson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).