aboutsummaryrefslogtreecommitdiff
path: root/repl
diff options
context:
space:
mode:
Diffstat (limited to 'repl')
-rw-r--r--repl/repl.go23
1 files changed, 3 insertions, 20 deletions
diff --git a/repl/repl.go b/repl/repl.go
index d766eff..5f2ee36 100644
--- a/repl/repl.go
+++ b/repl/repl.go
@@ -133,26 +133,9 @@ func rep(rl *readline.Instance, thread *starlark.Thread, globals starlark.String
if v != starlark.None {
fmt.Println(v)
}
- } else {
- // compile
- prog, err := starlark.FileProgram(f, globals.Has)
- if err != nil {
- PrintError(err)
- return nil
- }
-
- // execute (but do not freeze)
- res, err := prog.Init(thread, globals)
- if err != nil {
- PrintError(err)
- }
-
- // The global names from the previous call become
- // the predeclared names of this call.
- // If execution failed, some globals may be undefined.
- for k, v := range res {
- globals[k] = v
- }
+ } else if err := starlark.ExecREPLChunk(f, thread, globals); err != nil {
+ PrintError(err)
+ return nil
}
return nil