ok was unconditoinally throwing on any With var

This commit is contained in:
Ben Burdette 2021-09-23 13:02:39 -06:00
parent c07edb1932
commit b9d08b98da
2 changed files with 47 additions and 28 deletions

View file

@ -618,10 +618,10 @@ std::vector<std::shared_ptr<Installable>> SourceExprCommand::parseInstallables(
if (file) if (file)
state->evalFile(lookupFileArg(*state, *file), *vFile); state->evalFile(lookupFileArg(*state, *file), *vFile);
else { else {
std::cout << "pre parseExprFromString" << std::endl;
auto e = state->parseExprFromString(*expr, absPath(".")); auto e = state->parseExprFromString(*expr, absPath("."));
int x = 5; std::cout << "pre eval" << std::endl;
std::cout << "x =" << x << std::endl;
state->eval(e, *vFile); state->eval(e, *vFile);
} }

View file

@ -262,6 +262,20 @@ void ExprVar::bindVars(const std::shared_ptr<const StaticEnv> &env)
{ {
/* Check whether the variable appears in the environment. If so, /* Check whether the variable appears in the environment. If so,
set its level and displacement. */ set its level and displacement. */
std::cout << "ExprVar::bindVars " << name << std::endl;
int a = 10;
if (name == "callPackage") {
a++; // try to make code that I can put a breakpoint on...
std::cout << "meh" << a + 10 << std::endl;
int withLevel = -1;
fromWith = true;
// this->level = withLevel;
}
{
const StaticEnv * curEnv; const StaticEnv * curEnv;
unsigned int level; unsigned int level;
int withLevel = -1; int withLevel = -1;
@ -279,17 +293,21 @@ void ExprVar::bindVars(const std::shared_ptr<const StaticEnv> &env)
} }
} }
/* Otherwise, the variable must be obtained from the nearest /* Otherwise, the variable must be obtained from the nearest
enclosing `with'. If there is no `with', then we can issue an enclosing `with'. If there is no `with', then we can issue an
"undefined variable" error now. */ "undefined variable" error now. */
if (withLevel == -1) if (withLevel == -1)
{
std::cout << " throw UndefinedVarError({" << std::endl; std::cout << " throw UndefinedVarError({" << std::endl;
throw UndefinedVarError({ throw UndefinedVarError({
.msg = hintfmt("undefined variable '%1%'", name), .msg = hintfmt("undefined variable (ExprVar bindvars) '%1%'", name),
.errPos = pos .errPos = pos
}); });
}
fromWith = true; fromWith = true;
this->level = withLevel; this->level = withLevel;
}
} }
void ExprSelect::bindVars(const std::shared_ptr<const StaticEnv> &env) void ExprSelect::bindVars(const std::shared_ptr<const StaticEnv> &env)
@ -418,6 +436,7 @@ void ExprWith::bindVars(const std::shared_ptr<const StaticEnv> &env)
std::cout << "EvalState::parse newEnv " << i->first << std::endl; std::cout << "EvalState::parse newEnv " << i->first << std::endl;
std::cout << " body->bindVars(newEnv), iswith: " << newEnv->isWith << std::endl;
body->bindVars(newEnv); body->bindVars(newEnv);
std::cout << " ExprWith::bindVars 3" << std::endl; std::cout << " ExprWith::bindVars 3" << std::endl;
} }