Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/libcmd/repl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ static std::ostream & showDebugTrace(std::ostream & out, const PosTable & positi
return out;
}

MakeError(IncompleteReplExpr, ParseError);

static bool isFirstRepl = true;

ReplExitStatus NixRepl::mainLoop()
Expand Down Expand Up @@ -213,6 +215,7 @@ ReplExitStatus NixRepl::mainLoop()
default:
unreachable();
}
<<<<<<< HEAD
} 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
Expand All @@ -223,6 +226,10 @@ ReplExitStatus NixRepl::mainLoop()
}
} catch (EvalError & e) {
printMsg(lvlError, e.msg());
=======
} catch (IncompleteReplExpr &) {
continue;
>>>>>>> d8b067b54 (repl: Don't wait on incomplete parses from imported file)
} catch (Error & e) {
printMsg(lvlError, e.msg());
} catch (Interrupted & e) {
Expand Down Expand Up @@ -841,7 +848,17 @@ 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());
else
throw;
}
e->eval(*state, *env, v);
state->forceValue(v, v.determinePos(noPos));
}
Expand Down
6 changes: 6 additions & 0 deletions tests/functional/repl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,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
Expand Down
Loading