ok was unconditoinally throwing on any With var
This commit is contained in:
parent
c07edb1932
commit
b9d08b98da
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -262,34 +262,52 @@ 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. */
|
||||||
const StaticEnv * curEnv;
|
|
||||||
unsigned int level;
|
std::cout << "ExprVar::bindVars " << name << std::endl;
|
||||||
int withLevel = -1;
|
|
||||||
for (curEnv = env.get(), level = 0; curEnv; curEnv = curEnv->up, level++) {
|
int a = 10;
|
||||||
if (curEnv->isWith) {
|
if (name == "callPackage") {
|
||||||
if (withLevel == -1) withLevel = level;
|
a++; // try to make code that I can put a breakpoint on...
|
||||||
} else {
|
std::cout << "meh" << a + 10 << std::endl;
|
||||||
StaticEnv::Vars::const_iterator i = curEnv->vars.find(name);
|
int withLevel = -1;
|
||||||
if (i != curEnv->vars.end()) {
|
fromWith = true;
|
||||||
fromWith = false;
|
// this->level = withLevel;
|
||||||
this->level = level;
|
|
||||||
displ = i->second;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise, the variable must be obtained from the nearest
|
{
|
||||||
enclosing `with'. If there is no `with', then we can issue an
|
|
||||||
"undefined variable" error now. */
|
const StaticEnv * curEnv;
|
||||||
if (withLevel == -1)
|
unsigned int level;
|
||||||
std::cout << " throw UndefinedVarError({" << std::endl;
|
int withLevel = -1;
|
||||||
throw UndefinedVarError({
|
for (curEnv = env.get(), level = 0; curEnv; curEnv = curEnv->up, level++) {
|
||||||
.msg = hintfmt("undefined variable '%1%'", name),
|
if (curEnv->isWith) {
|
||||||
.errPos = pos
|
if (withLevel == -1) withLevel = level;
|
||||||
});
|
} else {
|
||||||
fromWith = true;
|
StaticEnv::Vars::const_iterator i = curEnv->vars.find(name);
|
||||||
this->level = withLevel;
|
if (i != curEnv->vars.end()) {
|
||||||
|
fromWith = false;
|
||||||
|
this->level = level;
|
||||||
|
displ = i->second;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Otherwise, the variable must be obtained from the nearest
|
||||||
|
enclosing `with'. If there is no `with', then we can issue an
|
||||||
|
"undefined variable" error now. */
|
||||||
|
if (withLevel == -1)
|
||||||
|
{
|
||||||
|
std::cout << " throw UndefinedVarError({" << std::endl;
|
||||||
|
throw UndefinedVarError({
|
||||||
|
.msg = hintfmt("undefined variable (ExprVar bindvars) '%1%'", name),
|
||||||
|
.errPos = pos
|
||||||
|
});
|
||||||
|
}
|
||||||
|
fromWith = true;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue