mirror of
https://github.com/NixOS/nix
synced 2025-06-24 22:11:15 +02:00
parent
37b4407c5c
commit
d8b067b549
2 changed files with 19 additions and 11 deletions
|
@ -158,6 +158,8 @@ static std::ostream & showDebugTrace(std::ostream & out, const PosTable & positi
|
|||
return out;
|
||||
}
|
||||
|
||||
MakeError(IncompleteReplExpr, ParseError);
|
||||
|
||||
static bool isFirstRepl = true;
|
||||
|
||||
ReplExitStatus NixRepl::mainLoop()
|
||||
|
@ -205,16 +207,8 @@ ReplExitStatus NixRepl::mainLoop()
|
|||
default:
|
||||
unreachable();
|
||||
}
|
||||
} catch (ParseError & e) {
|
||||
if (e.msg().find("unexpected end of file") != std::string::npos) {
|
||||
// For parse errors on incomplete input, we continue waiting for the next line of
|
||||
// input without clearing the input so far.
|
||||
continue;
|
||||
} else {
|
||||
printMsg(lvlError, e.msg());
|
||||
}
|
||||
} catch (EvalError & e) {
|
||||
printMsg(lvlError, e.msg());
|
||||
} catch (IncompleteReplExpr &) {
|
||||
continue;
|
||||
} catch (Error & e) {
|
||||
printMsg(lvlError, e.msg());
|
||||
} catch (Interrupted & e) {
|
||||
|
@ -837,7 +831,15 @@ Expr * NixRepl::parseString(std::string s)
|
|||
|
||||
void NixRepl::evalString(std::string s, Value & v)
|
||||
{
|
||||
Expr * e = parseString(s);
|
||||
Expr * e;
|
||||
try {
|
||||
e = parseString(s);
|
||||
} catch (ParseError & e) {
|
||||
if (e.msg().find("unexpected end of file") != std::string::npos)
|
||||
// For parse errors on incomplete input, we continue waiting for the next line of
|
||||
// input without clearing the input so far.
|
||||
throw IncompleteReplExpr(e.msg());
|
||||
}
|
||||
e->eval(*state, *env, v);
|
||||
state->forceValue(v, v.determinePos(noPos));
|
||||
}
|
||||
|
|
|
@ -277,6 +277,12 @@ testReplResponseNoRegex '
|
|||
}
|
||||
'
|
||||
|
||||
# Don't prompt for more input when getting unexpected EOF in imported files.
|
||||
testReplResponse "
|
||||
import $testDir/lang/parse-fail-eof-pos.nix
|
||||
" \
|
||||
'.*error: syntax error, unexpected end of file.*'
|
||||
|
||||
# TODO: move init to characterisation/framework.sh
|
||||
badDiff=0
|
||||
badExitCode=0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue