elves / elvish

Powerful scripting language & versatile interactive shell
https://elv.sh/
BSD 2-Clause "Simplified" License
5.69k stars 300 forks source link

possible regression at v0.15 when referencing some builtins #1524

Closed crinklywrappr closed 2 years ago

crinklywrappr commented 2 years ago

Prior to v0.15 I was able to do

put $+~

Since then Elvish throws an error. In v0.18:

parse error: 5-6 in [tty]: should be variable name
compilation error: 4-5 in [tty]: variable $ not found
parse error: should be variable name
[tty 1], line 1: put $+~

This still works for some builtins, though.

$ put $each~
▶ <builtin each>
krader1961 commented 2 years ago

The grammar was tightened up to avoid some ambiguities. Specifically, the definition of a bareword was changed. Commit 80e944be, 2021-01-12, introduced the ability to use characters not allowed in a bareword in a variable name by quoting the string. For example,

> put $'+~'
▶ <builtin +>
> var '+foo^' = foobar
> put $'+foo^'
▶ foobar

P.S., See also https://elv.sh/ref/language.html#variable-use