mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 01:47:51 +08:00
Merge branch 'master' into builtin-elvdoc
This commit is contained in:
commit
4c27a9e551
14
README.md
14
README.md
|
@ -2,7 +2,7 @@
|
|||
|
||||
[![CI status](https://github.com/elves/elvish/workflows/CI/badge.svg)](https://github.com/elves/elvish/actions?query=workflow%3ACI)
|
||||
[![FreeBSD & gccgo test status](https://img.shields.io/cirrus/github/elves/elvish?logo=Cirrus%20CI&label=CI2)](https://cirrus-ci.com/github/elves/elvish/master)
|
||||
[![Test Coverage](https://img.shields.io/codecov/c/github/elves/elvish/master.svg?logo=Codecov&label=coverage)](https://app.codecov.io/gh/elves/elvish/branch/master)
|
||||
[![Test Coverage](https://img.shields.io/codecov/c/github/elves/elvish/master.svg?logo=Codecov&label=coverage)](https://app.codecov.io/gh/elves/elvish/tree/master)
|
||||
[![Go Reference](https://pkg.go.dev/badge/src.elv.sh@master.svg)](https://pkg.go.dev/src.elv.sh@master)
|
||||
[![Packaging status](https://repology.org/badge/tiny-repos/elvish.svg)](https://repology.org/project/elvish/versions)
|
||||
[![Twitter](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/ElvishShell)
|
||||
|
@ -36,6 +36,18 @@ including:
|
|||
The source for the documentation is in the
|
||||
[website](https://github.com/elves/elvish/tree/master/website) directory.
|
||||
|
||||
## License
|
||||
|
||||
All source files use the BSD 2-clause license (see [LICENSE](LICENSE)), except
|
||||
for the following:
|
||||
|
||||
- Files in [pkg/rpc](pkg/rpc) are derived from the Go source, which uses the
|
||||
BSD 3-clause license. See [pkg/rpc/LICENSE](pkg/rpc/LICENSE).
|
||||
|
||||
- Some files in [pkg/persistent](pkg/persistent) and its subdirectories are
|
||||
partially derived from the Clojure source code, which uses EPL 1.0. See
|
||||
[pkg/persistent/LICENSE](pkg/persistent/LICENSE).
|
||||
|
||||
## Building Elvish
|
||||
|
||||
Most users do not need to build Elvish from source. Prebuilt binaries for the
|
||||
|
|
|
@ -81,6 +81,8 @@ func TestVar(t *testing.T) {
|
|||
ValidLow: 2, ValidHigh: -1, Actual: 1},
|
||||
"var x y @z = 1"),
|
||||
|
||||
// Variable name must not be empty
|
||||
That("var ''").DoesNotCompile(),
|
||||
// Variable name that must be quoted after $ must be quoted
|
||||
That("var a/b").DoesNotCompile(),
|
||||
// Multiple @ not allowed
|
||||
|
@ -91,6 +93,8 @@ func TestVar(t *testing.T) {
|
|||
That("var a[0]").DoesNotCompile(),
|
||||
// Composite expression not allowed
|
||||
That("var a'b'").DoesNotCompile(),
|
||||
// Braced lists must not have any indices when used as a lvalue.
|
||||
That("var {a b}[0] = x y").DoesNotCompile(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -66,20 +66,23 @@ func (cp *compiler) parseIndexingLValue(n *parse.Indexing, f lvalueFlag) lvalues
|
|||
}
|
||||
varUse := n.Head.Value
|
||||
sigil, qname := SplitSigil(varUse)
|
||||
if qname == "" {
|
||||
cp.errorpf(n, "variable name must not be empty")
|
||||
}
|
||||
|
||||
var ref *varRef
|
||||
if f&setLValue != 0 {
|
||||
ref = resolveVarRef(cp, qname, n)
|
||||
if ref != nil && len(ref.subNames) == 0 && ref.info.readOnly {
|
||||
cp.errorpf(n, "variable $%s is read-only", qname)
|
||||
cp.errorpf(n, "variable $%s is read-only", parse.Quote(qname))
|
||||
}
|
||||
}
|
||||
if ref == nil {
|
||||
if f&newLValue == 0 {
|
||||
cp.errorpf(n, "cannot find variable $%s", qname)
|
||||
cp.errorpf(n, "cannot find variable $%s", parse.Quote(qname))
|
||||
}
|
||||
if len(n.Indices) > 0 {
|
||||
cp.errorpf(n, "name for new variable must not have indices")
|
||||
cp.errorpf(n, "new variable $%s must not have indices", parse.Quote(qname))
|
||||
}
|
||||
segs := SplitQNameSegs(qname)
|
||||
if len(segs) == 1 {
|
||||
|
@ -88,7 +91,9 @@ func (cp *compiler) parseIndexingLValue(n *parse.Indexing, f lvalueFlag) lvalues
|
|||
ref = &varRef{localScope,
|
||||
staticVarInfo{name, false, false}, cp.thisScope().add(name), nil}
|
||||
} else {
|
||||
cp.errorpf(n, "cannot create variable $%s; new variables can only be created in the local scope", qname)
|
||||
cp.errorpf(n, "cannot create variable $%s; "+
|
||||
"new variables can only be created in the current scope",
|
||||
parse.Quote(qname))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -262,7 +262,7 @@ func (cp *compiler) primaryOp(n *parse.Primary) valuesOp {
|
|||
sigil, qname := SplitSigil(n.Value)
|
||||
ref := resolveVarRef(cp, qname, n)
|
||||
if ref == nil {
|
||||
cp.errorpf(n, "variable $%s not found", qname)
|
||||
cp.errorpf(n, "variable $%s not found", parse.Quote(qname))
|
||||
}
|
||||
return &variableOp{n.Range(), sigil != "", qname, ref}
|
||||
case parse.Wildcard:
|
||||
|
@ -313,7 +313,7 @@ type variableOp struct {
|
|||
func (op variableOp) exec(fm *Frame) ([]any, Exception) {
|
||||
variable := deref(fm, op.ref)
|
||||
if variable == nil {
|
||||
return nil, fm.errorpf(op, "variable $%s not found", op.qname)
|
||||
return nil, fm.errorpf(op, "variable $%s not found", parse.Quote(op.qname))
|
||||
}
|
||||
value := variable.Get()
|
||||
if op.explode {
|
||||
|
|
27
pkg/rpc/LICENSE
Normal file
27
pkg/rpc/LICENSE
Normal file
|
@ -0,0 +1,27 @@
|
|||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
Loading…
Reference in New Issue
Block a user