elves / upgrade-scripts-for-0.17 Goto Github PK
View Code? Open in Web Editor NEWUpgrade Elvish scripts for 0.17
License: BSD 2-Clause "Simplified" License
Upgrade Elvish scripts for 0.17
License: BSD 2-Clause "Simplified" License
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
I ran upgrade-scripts-for-0.17 -w **.elv
in my ~/.config/elvish directory. It reported a bunch of errors like this one:
Multiple parse errors:
should be variable name
[stdin], line 174:
&su= $&segment_su
It wasn't hard to find the offending script but it would be nice if the error message reported the pathname rather than [stdin]
. In this case the error(s) were due to lib/github.com/muesli/elvish-libs/theme/muesli.elv that I installed long, long, ago but never used after trying it once. It might also be better to simply stop after the first parse error since a parse error means that any further effort to convert the script is unlikely to yield useful results and likely to result in a lot of additional parse errors.
This is just a FYI. I do not actually expect any changes to accommodate this scenario. I accidentally ran this tool twice in a row using the latest version of the tool as I write this:
upgrade-scripts-for-0.17 -lambda -w **[type:regular].elv
That resulted in a sequence of errors like this:
Multiple parse errors:
should be '}'
lib/interactive.elv, line 31:
fn hr {||]
unexpected rune ']'
lib/interactive.elv, line 31:
fn hr {||]
Which is not at all surprising yet still surprised me. It made we ponder whether it is possible to do better by only converting a file once? The obvious approach is to add a prefix, such as "# elvish 0.17.0\n", to the transformed output. The presence of that prefix causes the conversion tool to ignore the file. That, however, is a fragile mechanism with ambiguities. I don't expect this to be resolved but wanted to document the problem in case there was an obvious (other than to me) solution.
Minmal example:
⬥ echo 'x = []{ nop }' | upgrade-scripts-for-0.17 -lambda
var x = {||] nop }
I have no idea why one of my scripts used this construct, but it did. It's an odd corner case that nevertheless should be fixed.
Edited to add: No problem with [ ]{ nop }
. A single space makes all the difference.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.