On Thu, May 18, 2023 at 5:14 PM Oliver Kiddle wrote: > > integer .var.d=0 > (( .var.d++ )) > zsh: bad floating point constant > > It'd be good if it could identify this as a namespace variable. This should be correctly handled after this patch, test is included. If you find other broken edge cases please point them out. On Thu, May 25, 2023 at 3:09 PM Bart Schaefer wrote: > > On Wed, May 24, 2023 at 9:41 AM Oliver Kiddle wrote: > > > > integer .var=56 > > > > would be disallowed. > > I had it that way at one point and backed off because ksh allows it. Patch below leaves this unchanged (so still allowed) and adds a test for it. > Strictly speaking (to the extent that any of this is strict), > namespaces are supposed to otherwise obey the rules for identifiers, > which with the exception of positional parameters are not allowed to > begin with a digit ... so I think I'll just go with that. > > I still haven't worked out how to deal correctly with .var.3x The below enforces that identifiers following a namespace prefix must either begin with a non-digit or must consist entirely of digits. For possible future enhancements, this does not apply when the identifier before the first "." does not itself begin with a ".", that is, ${var.3x} is allowed. I haven't determined how/where to document that latter special case. Perhaps it's not necessary to do so, given that omitting the first "." is explicitly discouraged. > > Also questionable is the following which currently works: > > > > .a.=ddd This is rejected by the patch (not an identifier / bad substitution). I think the extra checks add very little if any overhead to the unaffected cases but I haven't run benchmarks. > > We also currently allow a.=ddd but I think that is less > > questionable. We allow empty association elements. > > I'm still not entirely sold on the x.y <=> x[y] mapping idea, but if > we follow JavaScript's (somewhat questionable) lead on this, empty > elements have to use bracket-notation rather than dot-notation. I've not [yet] enforced the bracket-notation requirement, so as a special case of the ${var.3x} case above, ${var.} is also allowed. A point against following JS is that JS doesn't have the braces around the reference to delineate the empty element.