google / starlark-go

Starlark in Go: the Starlark configuration language, implemented in Go
BSD 3-Clause "New" or "Revised" License
2.34k stars 212 forks source link

REPL: doesn't load properly #224

Closed mcuadros closed 1 year ago

mcuadros commented 5 years ago

Unless I am doing something wrong, load inside of a REPL, doesn't load the object to the global scope.

> cat foo.star
foo = 42

> starlark
Welcome to Starlark (go.starlark.net)
>>> load("foo.star", "foo")
>>> foo
<stdin>:1:1: undefined: foo
>>>
alandonovan commented 5 years ago

Yikes, thanks for pointing this out. This appears to be a regression caused by 754257e: load bindings are now local to the "file". Each chunk (e.g. line) of REPL input is a file, so the REPL will need to work harder to dig the load bindings out of one "file" and transfer them to the next one.

adonovan commented 1 year ago

Fixed by the previous PR.