mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 18:07:51 +08:00
Warn about deprecated syntax features in imported modules.
This fixes #1072.
This commit is contained in:
parent
45b12127f6
commit
e5e0446c5a
|
@ -283,7 +283,7 @@ func source(fm *Frame, fname string) error {
|
|||
return err
|
||||
}
|
||||
src := parse.Source{Name: fname, Code: code, IsFile: true}
|
||||
tree, err := parse.Parse(src)
|
||||
tree, err := parse.ParseWithDeprecation(src, fm.ports[2].File)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -299,7 +299,7 @@ func loadModuleFile(fm *Frame, r diag.Ranger, spec, path string) (Ns, error) {
|
|||
}
|
||||
|
||||
func evalModule(fm *Frame, r diag.Ranger, key string, src parse.Source) (Ns, error) {
|
||||
tree, err := parse.Parse(src)
|
||||
tree, err := parse.ParseWithDeprecation(src, fm.ports[2].File)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/elves/elvish/pkg/eval/errs"
|
||||
"github.com/elves/elvish/pkg/prog"
|
||||
"github.com/elves/elvish/pkg/util"
|
||||
)
|
||||
|
||||
|
@ -160,3 +161,17 @@ func TestUse(t *testing.T) {
|
|||
That("use a b c").DoesNotCompile(),
|
||||
)
|
||||
}
|
||||
|
||||
// Regression test for #1072
|
||||
func TestUse_WarnsAboutDeprecatedSyntax(t *testing.T) {
|
||||
restore := prog.SetShowDeprecations(true)
|
||||
defer restore()
|
||||
libdir, cleanup := util.InTestDir()
|
||||
defer cleanup()
|
||||
mustWriteFile("dep.elv", []byte("a = \\\n1"), 0600)
|
||||
|
||||
TestWithSetup(t, func(ev *Evaler) { ev.SetLibDir(libdir) },
|
||||
// Importing module triggers check for deprecated syntax features
|
||||
That("use dep").PrintsStderrWith("is deprecated"),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user