elves / upgrade-scripts-for-0.17

Upgrade Elvish scripts for 0.17
BSD 2-Clause "Simplified" License
4 stars 2 forks source link

Vars qualified with a `local:` namespace prefix aren't handled correctly #2

Closed krader1961 closed 3 years ago

krader1961 commented 3 years ago

Long ago, when I first started using Elvish, I wrote a nx function. Its purpose is to run an external command and ignore specific non-zero exit status exceptions. The function employs the local: namespace prefix. This statement:

local:exc = $ok

Was mutated to this:

var local:exc = $ok

Which results in this error when starting a new Elvish shell:

Exception: compilation error: variable declared in var must be unqualified
/Users/krader/.config/elvish/lib/util.elv, line 104:     var local:exc = $ok
/Users/krader/.config/elvish/rc.elv, line 37: use util
krader1961 commented 3 years ago

Replacing var local:... with set local:... in my module revealed a similar error in a third-party module by @zzamboni:

Exception: compilation error: variable declared in var must be unqualified
/Users/krader/.config/elvish/lib/github.com/zzamboni/elvish-modules/util.elv, line 38:   var local:line = (if $prompt {
/Users/krader/.config/elvish/rc.elv, line 61: use github.com/zzamboni/elvish-modules/util zutil
krader1961 commented 3 years ago

Fixing the error in my previous comment reveals another instance of the same problem:

Exception: compilation error: variable declared in var must be unqualified
/Users/krader/.config/elvish/lib/github.com/zzamboni/elvish-modules/tty.elv, line 5:   var local:stty = (stty -g </dev/tty)
Traceback:
  /Users/krader/.config/elvish/lib/github.com/zzamboni/elvish-modules/spinners.elv, line 3:
    use github.com/zzamboni/elvish-modules/tty
  /Users/krader/.config/elvish/lib/github.com/zzamboni/elvish-themes/chain.elv, line 14:
    use github.com/zzamboni/elvish-modules/spinners
  /Users/krader/.config/elvish/lib/prompt.elv, line 3:
    use github.com/zzamboni/elvish-themes/chain
  /Users/krader/.config/elvish/rc.elv, line 91:
      use prompt
xiaq commented 3 years ago

It seems you're not running with the latest HEAD; https://github.com/elves/elvish/commit/6a7d99041d1e1f27c0df79d8ce947e5279244b0e updated var to accept forms like var local:a as valid.

xiaq commented 3 years ago

Hmm, this should probably be fixed nonetheless in order for the converted script to be compatible with 0.16.x.

krader1961 commented 3 years ago

I currently have 0.17.0-dev.9076934395344d308180dd36ba289285dd7af779+macpro.skepticism.us installed. So reasonably current (less than two months old) but as you noted the upgrade program really needs to work with the 0.16.0 version of elvish.