diff --git a/environment.go b/environment.go index 0d6d2ea..a06aa6d 100644 --- a/environment.go +++ b/environment.go @@ -36,9 +36,9 @@ func (env *Environment) Get(name string, exp *Expr) interface{} { func (env *Environment) Set(name string, value interface{}, exp *Expr) interface{} { scope := env.Lookup(name) - if scope == nil && env.parent != nil { - Error(exp, "Undefined variable '%s'", name) - } + // if scope == nil && env.parent != nil { + // Error(exp, "Undefined variable '%s'", name) + // } if scope != nil { scope.vars[name] = value } else { diff --git a/example/test.rune b/example/test.rune index a4d86af..9da154e 100644 --- a/example/test.rune +++ b/example/test.rune @@ -1,3 +1,14 @@ +foo = "bar" +exit() + +testFun = fun() { + foo = "bar" + println(foo) +} + +testFun() + +exit() fibonacci = fun(n) { if n <= 0 then return = 0 elif n == 1 then return = 1