Commit Graph

36 Commits

Author SHA1 Message Date
Qi Xiao
5a237d7888 pkg/eval: When compiling, emit autofixes for using unimported builtin modules. 2022-12-11 14:21:09 +00:00
Qi Xiao
121509d8d2 pkg/eval: Preserve all compilation errors.
Multiple compilation errors are packed using diag.PackCognateErrors, like parse errors.
2022-11-30 01:40:03 +00:00
Qi Xiao
69715b05fe pkg/eval: Don't use panics for propagating compilation errors.
This also enables saving multiple compilation errors.
2022-11-29 21:17:13 +00:00
Qi Xiao
3ff0e4bcd9 pkg/eval: Check whether variable name is empty when parsing lvalue.
This fixes #1560.
2022-10-03 04:34:05 +01:00
Kurtis Rader
e896ac3c0e
Improve some compilation errors (#1617)
Quote variable names appearing in some compilation errors to improve
the clarity of those errors.
2022-10-03 04:22:46 +01:00
Qi Xiao
d4dd11a981 pkg/eval/vars: Deexport EnvVariable, use Unset/IsSet via interface 2022-06-05 21:47:51 +01:00
Qi Xiao
26a66284a9 Fixup for #1551. 2022-06-05 16:01:10 +01:00
Tw
d27610b3e4 Fix undefined temporary environment restoring issue
Close #1536

Signed-off-by: Tw <tw19881113@gmail.com>
2022-06-05 15:41:19 +01:00
Qi Xiao
51e4d97568 interface{} -> any now that Elvish requires Go 1.18. 2022-03-20 16:17:19 +00:00
Qi Xiao
be1e144b45 Remove support for the "local:", "up:" and ":" special namespaces.
This fixes #1409.
2022-01-03 00:47:41 +00:00
Qi Xiao
973fe39798 Implement the tmp special command.
This addresses #1114.
2021-12-09 22:12:38 +00:00
Qi Xiao
6822e2ca7b Deprecate the local: and up: special namespaces in 0.17.
Also deprecate the use of a leading empty namespace.

This addresses #1409.
2021-10-15 22:45:02 +01:00
Qi Xiao
6a92571a23 Check assignments to read-only variable during compilation. 2021-10-13 23:57:14 +01:00
Qi Xiao
6a7d99041d pkg/eval: Require the variable used in "set" to already exist.
This has always been the documented behavior, but up until this point, "set"
actually behaved like the legacy assignment form, which creates the variable if
it doesn't exist yet.

This fixes the discrepancy. Addresses #645.
2021-10-10 14:31:09 +01:00
Qi Xiao
4d62732ebc Fix "indicies" -> indices. 2021-08-22 23:31:26 +01:00
Kurtis Rader
9a576529a3 Replace ErrArgs with more specific errors
This also replaces the slightly awkward "arguments here" reason with
"argument count" as the "what" for a typical errs.ArityMismatch
exception. It also reformats most of the constructors so that the "what"
is on the same line. This makes `grep errs.ArityMismatch **.go` more
useful as a result.
2021-06-13 22:42:04 +01:00
Kurtis Rader
f67c7ed387 A couple of TODO cleanups 2021-05-30 00:40:42 +01:00
Qi Xiao
a33ecb2da4 When variable cannot set, point to the variable in the stack trace.
This fixes #255.
2021-02-21 11:53:05 +00:00
Qi Xiao
196eea21d4 Change module import path to src.elv.sh 2021-01-27 01:30:25 +00:00
Qi Xiao
072677351b Introduce "var" and "set".
Assignment using "foo = bar" instead of "var foo = bar" or "set foo = bar" is
not yet deprecated, but will be soon.

This addresses #645.
2021-01-16 06:11:37 +00:00
Qi Xiao
2defb9c53a pkg/eval: Correctly handle variable lookup error during runtime.
This fixes #1214.
2021-01-10 13:30:07 +00:00
Qi Xiao
af906f1d76 pkg/eval: Change all the *Op types to return Exception instead of error.
Also change the variable name used to keep the Exception returned from "err" to
"exc".

This uncovers several error scenarios that were not returning Exception, and
would result in the absense of stack traces when such errors occur.
2021-01-09 00:25:32 +00:00
Qi Xiao
719314c029 pkg/eval: Various cleanups for qname handling code. 2020-12-25 22:31:52 +00:00
Qi Xiao
6419f4524a Implement namespaces using slices instead of maps.
More related improvements and cleanups will be done in followup commits.

This fixes #1139.
2020-12-25 17:46:46 +00:00
Shengjing Zhu
6c08de0ff3 Fix typos found by codespell 2020-10-10 22:47:50 +01:00
Qi Xiao
b04ea12d48 pkg/eval: Refactor effectOp and valuesOp, remove lvaluesOp.
* Make effectOp and valuesOp interfaces - implementations now handle the
  range information themselves.

* Remove lvaluesOp; it is no longer used.
2020-08-22 19:57:11 +01:00
Qi Xiao
1e2ead56e2 pkg/eval: Rewrite the lvalue parsing code.
Also lift the restriction on rest variables and rest arguments - they may now
appear anywhere, as long as there is only one.
2020-08-20 13:15:00 +01:00
Kurtis Rader
eb2a792301 Fix some lint warnings
In addition to an uncontroversial spelling fix this addresses several,
related, warnings produced by the `golint` tool. In general I agree with
golint that unnecessary "else" blocks should be avoided. So this change
refactors those cases.

Note: I recognize that `golint` is deprecated (see
https://github.com/golang/go/issues/38968) since it is no longer being
maintained and there is controversy about its set of warnings. Nonetheless,
it appears that the warnings it emits for this project are all reasonable
and actionable with one potential exception: the naming of the `map_`
method in pkg/eval/compile_value.go.
2020-08-01 23:07:50 +01:00
Qi Xiao
c767f92d01 Support compile-time deprecation.
This fixes #898.
2020-04-26 13:14:51 +01:00
Qi Xiao
ffa9727f14 pkg/eval: Remove Frame.srcRange.
Maintaining a state of current range is error-prone. Instead, always keep track
of range information explicitly.
2020-04-09 20:44:09 +01:00
Qi Xiao
8c71635ca3 pkg/eval: Move all assignments to the start of the pipeline they belong in.
This avoids race conditions of accessing the local scope. The test case
"x = 1", "put $x | y = (all)" used to contain a race condition but no longer
does.

This addresses #73.
2020-03-28 23:49:30 +00:00
Qi Xiao
e6b7d06e80 [cleanup] pkg/eval: Remove compiler.errorf and compiler.compiling.
All errors are now written using compiler.errorpf.
2020-03-28 21:33:55 +00:00
Qi Xiao
d306f33af6 [cleanup] pkg/eval: Let compiler.errorpf accept a single diag.Ranger. 2020-03-28 21:33:55 +00:00
Qi Xiao
11919e83ec [cleanup] pkg/eval: use diag.Ranging in op types. 2020-03-28 21:33:55 +00:00
Qi Xiao
4fb04bc27a pkg/eval: Catch index write access to nonexistent variables.
This fixes #889.
2020-01-12 08:23:37 -05:00
Qi Xiao
e45fdf7228 Move all libraries to new pkg/. 2019-12-23 20:00:59 +00:00