Deprecate the legacy lambda syntax from 0.17.x.

This addresses #664.
This commit is contained in:
Qi Xiao 2021-10-14 23:10:29 +01:00
parent 6a92571a23
commit 4b218d9859
3 changed files with 13 additions and 2 deletions

View File

@ -16,8 +16,12 @@ or compiled, even if it is not executed:
- The `dir-history` command is deprecated. Use `store:dirs` instead.
- The legacy assignment form is deprecated. Depending on whether the left-hand
variable already exists or not, use `var` or `set` instead. There is a
dedicated program to help migrate scripts; see https://go.elv.sh/u0.17.
variable already exists or not, use `var` or `set` instead. Use the
[upgrader](https://go.elv.sh/u0.17) to migrate scripts.
- The lambda syntax that declares arguments and options within `[]` before `{`
has been deprecated. The new syntax now declares arguments and options
within a pair of `|`, after `{`.
# Notable new features

View File

@ -367,6 +367,9 @@ func (op outputCaptureOp) exec(fm *Frame) ([]interface{}, Exception) {
}
func (cp *compiler) lambda(n *parse.Primary) valuesOp {
if n.LegacyLambda {
cp.deprecate(n, "legacy lambda syntax is deprecated; migrate scripts with https://go.elv.sh/u0.17", 17)
}
// Parse signature.
var (
argNames []string

View File

@ -234,3 +234,7 @@ func TestClosure(t *testing.T) {
That("[@a @b]{ }").DoesNotCompile(),
)
}
func TestClosure_LegacySyntaxIsDeprecated(t *testing.T) {
testCompileTimeDeprecation(t, "a = []{ }", "legacy lambda syntax is deprecated", 17)
}