mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
Fix use of the builtin module via explicit "builtin".
Some of the variables are added after the Evaler is created, but that change was not synchronized back to the copy of the builtin module that is imported with "use builtin". This fixes #1414.
This commit is contained in:
parent
d71e52cbd7
commit
c1dce661b7
17
pkg/eval/builtin_ns_test.go
Normal file
17
pkg/eval/builtin_ns_test.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
package eval_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
. "src.elv.sh/pkg/eval"
|
||||
. "src.elv.sh/pkg/eval/evaltest"
|
||||
"src.elv.sh/pkg/eval/vals"
|
||||
)
|
||||
|
||||
func TestExplicitBuiltinModule(t *testing.T) {
|
||||
TestWithSetup(t, func(ev *Evaler) { ev.Args = vals.MakeList("a", "b") },
|
||||
That("all $args").Puts("a", "b"),
|
||||
// Regression test for #1414
|
||||
That("use builtin; all $builtin:args").Puts("a", "b"),
|
||||
)
|
||||
}
|
|
@ -154,8 +154,8 @@ func NewEvaler() *Evaler {
|
|||
|
||||
deprecations: newDeprecationRegistry(),
|
||||
|
||||
modules: map[string]*Ns{"builtin": builtin},
|
||||
BundledModules: map[string]string{},
|
||||
modules: make(map[string]*Ns),
|
||||
BundledModules: make(map[string]string),
|
||||
|
||||
valuePrefix: defaultValuePrefix,
|
||||
notifyBgJobSuccess: defaultNotifyBgJobSuccess,
|
||||
|
@ -180,6 +180,9 @@ func NewEvaler() *Evaler {
|
|||
vars.FromGet(func() interface{} { return strconv.Itoa(ev.getNumBgJobs()) })).
|
||||
AddVar("args", vars.FromGet(func() interface{} { return ev.Args })))
|
||||
|
||||
// Install the "builtin" module after extension is complete.
|
||||
ev.modules["builtin"] = ev.builtin
|
||||
|
||||
return ev
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user