oils-for-unix / oils

Oils is our upgrade path from bash to a better language and runtime. It's also for Python and JavaScript users who avoid shell!
http://www.oilshell.org/
Other
2.84k stars 157 forks source link

Don't push a new frame in `eval ()` #2047

Closed PossiblyAShrub closed 2 months ago

PossiblyAShrub commented 2 months ago

This test captures the effect of this change:

#### eval with vars follows same scoping as without
proc local-scope {
  var myVar = "foo"
  eval (^(echo $myVar), vars={ someOtherVar: "bar" })
  eval (^(echo $myVar))
}

# In global scope
var myVar = "baz"
eval (^(echo $myVar), vars={ someOtherVar: "bar" })
eval (^(echo $myVar))

local-scope
## STDOUT:
baz
baz
foo
foo
## END
andychu commented 2 months ago

Awesome, thank you! Now my question is if we should also use ctx_Eval for TWO places in Hay

I'll post on Zulip