mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
parent
be1e144b45
commit
003557c22a
|
@ -3,6 +3,8 @@ This is the draft release notes for 0.18.0, scheduled to be released around
|
|||
|
||||
# Breaking changes
|
||||
|
||||
- All features deprecated in 0.17.0 have been removed.
|
||||
|
||||
- Within double quotes, `\x` followed by two hexadecimal digits and `\`
|
||||
followed by three octal digits now encode an individual byte, rather than a
|
||||
codepoint.
|
||||
|
|
|
@ -3,7 +3,7 @@ set after-command = [
|
|||
# as a convenience for prompt functions. Note: The first time this is run is after
|
||||
# shell.sourceRC() finishes so the initial value of command-duration is the time
|
||||
# to execute the user's interactive configuration script.
|
||||
[m]{
|
||||
{|m|
|
||||
set command-duration = $m[duration]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -367,9 +367,6 @@ 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
|
||||
|
|
|
@ -220,7 +220,3 @@ func TestClosure(t *testing.T) {
|
|||
That("{|@a @b| }").DoesNotCompile(),
|
||||
)
|
||||
}
|
||||
|
||||
func TestClosure_LegacySyntaxIsDeprecated(t *testing.T) {
|
||||
testCompileTimeDeprecation(t, "a = []{ }", "legacy lambda syntax is deprecated", 17)
|
||||
}
|
||||
|
|
|
@ -493,8 +493,6 @@ type Primary struct {
|
|||
node
|
||||
ExprCtx ExprCtx
|
||||
Type PrimaryType
|
||||
// Legacy lambda uses [args]{ body } instead of { |args| body }
|
||||
LegacyLambda bool
|
||||
// The unquoted string value. Valid for Bareword, SingleQuoted,
|
||||
// DoubleQuoted, Variable, Wildcard and Tilde.
|
||||
Value string
|
||||
|
@ -828,45 +826,38 @@ items:
|
|||
if !parseSep(pn, ps, ']') {
|
||||
ps.error(errShouldBeRBracket)
|
||||
}
|
||||
if parseSep(pn, ps, '{') {
|
||||
pn.LegacyLambda = true
|
||||
pn.lambda(ps)
|
||||
} else {
|
||||
if loneAmpersand || len(pn.MapPairs) > 0 {
|
||||
if len(pn.Elements) > 0 {
|
||||
// TODO(xiaq): Add correct position information.
|
||||
ps.error(errBothElementsAndPairs)
|
||||
}
|
||||
pn.Type = Map
|
||||
} else {
|
||||
pn.Type = List
|
||||
if loneAmpersand || len(pn.MapPairs) > 0 {
|
||||
if len(pn.Elements) > 0 {
|
||||
// TODO(xiaq): Add correct position information.
|
||||
ps.error(errBothElementsAndPairs)
|
||||
}
|
||||
pn.Type = Map
|
||||
} else {
|
||||
pn.Type = List
|
||||
}
|
||||
}
|
||||
|
||||
// lambda parses a lambda expression. The opening brace has been seen.
|
||||
func (pn *Primary) lambda(ps *parser) {
|
||||
pn.Type = Lambda
|
||||
if !pn.LegacyLambda {
|
||||
parseSpacesAndNewlines(pn, ps)
|
||||
if parseSep(pn, ps, '|') {
|
||||
parseSpacesAndNewlines(pn, ps)
|
||||
if parseSep(pn, ps, '|') {
|
||||
items:
|
||||
for {
|
||||
r := ps.peek()
|
||||
switch {
|
||||
case r == '&':
|
||||
ps.parse(&MapPair{}).addTo(&pn.MapPairs, pn)
|
||||
case startsCompound(r, NormalExpr):
|
||||
ps.parse(&Compound{}).addTo(&pn.Elements, pn)
|
||||
default:
|
||||
break items
|
||||
}
|
||||
parseSpacesAndNewlines(pn, ps)
|
||||
items:
|
||||
for {
|
||||
r := ps.peek()
|
||||
switch {
|
||||
case r == '&':
|
||||
ps.parse(&MapPair{}).addTo(&pn.MapPairs, pn)
|
||||
case startsCompound(r, NormalExpr):
|
||||
ps.parse(&Compound{}).addTo(&pn.Elements, pn)
|
||||
default:
|
||||
break items
|
||||
}
|
||||
parseSpacesAndNewlines(pn, ps)
|
||||
}
|
||||
if !parseSep(pn, ps, '|') {
|
||||
ps.error(errShouldBePipe)
|
||||
}
|
||||
}
|
||||
if !parseSep(pn, ps, '|') {
|
||||
ps.error(errShouldBePipe)
|
||||
}
|
||||
}
|
||||
ps.parse(&Chunk{}).addAs(&pn.Chunk, pn)
|
||||
|
|
|
@ -343,49 +343,23 @@ var testCases = []struct {
|
|||
),
|
||||
},
|
||||
{
|
||||
name: "lambda",
|
||||
code: "a []{} [ ]{ } []{ echo 233 } [ x y ]{puts $x $y} { put haha}",
|
||||
node: &Chunk{},
|
||||
want: a(
|
||||
ast{"Compound/Indexing/Primary", fs{
|
||||
"Type": Lambda, "LegacyLambda": true, "Elements": []ast{}, "Chunk": "",
|
||||
}},
|
||||
ast{"Compound/Indexing/Primary", fs{
|
||||
"Type": Lambda, "LegacyLambda": true, "Elements": []ast{}, "Chunk": " ",
|
||||
}},
|
||||
ast{"Compound/Indexing/Primary", fs{
|
||||
"Type": Lambda, "LegacyLambda": true, "Elements": []ast{}, "Chunk": " echo 233 ",
|
||||
}},
|
||||
ast{"Compound/Indexing/Primary", fs{
|
||||
"Type": Lambda, "LegacyLambda": true, "Elements": []string{"x", "y"}, "Chunk": "puts $x $y",
|
||||
}},
|
||||
ast{"Compound/Indexing/Primary", fs{
|
||||
"Type": Lambda, "Elements": []ast{}, "Chunk": "put haha",
|
||||
}},
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "new-style lambda with arguments and options",
|
||||
code: "{|a b &k=v|}",
|
||||
name: "lambda without signature",
|
||||
code: "{ echo}",
|
||||
node: &Primary{},
|
||||
want: ast{"Primary", fs{
|
||||
"Type": Lambda,
|
||||
"LegacyLambda": false,
|
||||
"Elements": []string{"a", "b"},
|
||||
"MapPairs": []string{"&k=v"},
|
||||
"Chunk": "",
|
||||
"Type": Lambda,
|
||||
"Chunk": "echo",
|
||||
}},
|
||||
},
|
||||
{
|
||||
name: "legacy lambda with arguments and options",
|
||||
code: "[a b &k=v]{}",
|
||||
name: "new-style lambda with arguments and options",
|
||||
code: "{|a b &k=v| echo}",
|
||||
node: &Primary{},
|
||||
want: ast{"Primary", fs{
|
||||
"Type": Lambda,
|
||||
"LegacyLambda": true,
|
||||
"Elements": []string{"a", "b"},
|
||||
"MapPairs": []string{"&k=v"},
|
||||
"Chunk": "",
|
||||
"Type": Lambda,
|
||||
"Elements": []string{"a", "b"},
|
||||
"MapPairs": []string{"&k=v"},
|
||||
"Chunk": " echo",
|
||||
}},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -13,19 +13,19 @@ var pprintASTTests = tt.Table{
|
|||
tt.Args(n).Rets(
|
||||
`Chunk
|
||||
Pipeline/Form
|
||||
Compound/Indexing/Primary ExprCtx=CmdExpr Type=Bareword LegacyLambda=false Value="ls"
|
||||
Compound/Indexing/Primary ExprCtx=CmdExpr Type=Bareword Value="ls"
|
||||
Compound ExprCtx=NormalExpr
|
||||
Indexing ExprCtx=NormalExpr
|
||||
Primary ExprCtx=NormalExpr Type=Variable LegacyLambda=false Value="x"
|
||||
Array/Compound/Indexing/Primary ExprCtx=NormalExpr Type=Bareword LegacyLambda=false Value="0"
|
||||
Primary ExprCtx=NormalExpr Type=Variable Value="x"
|
||||
Array/Compound/Indexing/Primary ExprCtx=NormalExpr Type=Bareword Value="0"
|
||||
Indexing ExprCtx=NormalExpr
|
||||
Primary ExprCtx=NormalExpr Type=Variable LegacyLambda=false Value="y"
|
||||
Array/Compound/Indexing/Primary ExprCtx=NormalExpr Type=Bareword LegacyLambda=false Value="1"
|
||||
Primary ExprCtx=NormalExpr Type=Variable Value="y"
|
||||
Array/Compound/Indexing/Primary ExprCtx=NormalExpr Type=Bareword Value="1"
|
||||
Pipeline/Form
|
||||
Compound/Indexing/Primary ExprCtx=CmdExpr Type=Bareword LegacyLambda=false Value="echo"
|
||||
Compound/Indexing/Primary ExprCtx=NormalExpr Type=Bareword LegacyLambda=false Value="done"
|
||||
Compound/Indexing/Primary ExprCtx=CmdExpr Type=Bareword Value="echo"
|
||||
Compound/Indexing/Primary ExprCtx=NormalExpr Type=Bareword Value="done"
|
||||
Redir Mode=Write RightIsFd=false
|
||||
Compound/Indexing/Primary ExprCtx=NormalExpr Type=Bareword LegacyLambda=false Value="/redir-dest"
|
||||
Compound/Indexing/Primary ExprCtx=NormalExpr Type=Bareword Value="/redir-dest"
|
||||
`),
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user