From 0a3eb22360bdb5e948ef8e7cb8f41958c541b54b Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Sat, 19 Jul 2025 23:52:32 +0200 Subject: [PATCH] fix: wait on incomplete assignment in REPL Fixes: https://github.com/NixOS/nix/issues/13507 --- src/libcmd/repl.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index 5c6dd7ffb..38d06336b 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -869,14 +869,8 @@ void NixRepl::addVarToScope(const Symbol name, Value & v) Expr * NixRepl::parseString(std::string s) { - return state->parseExprFromString(std::move(s), state->rootPath("."), staticEnv); -} - -void NixRepl::evalString(std::string s, Value & v) -{ - Expr * e; try { - e = parseString(s); + return state->parseExprFromString(std::move(s), state->rootPath("."), staticEnv); } 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 @@ -885,6 +879,11 @@ void NixRepl::evalString(std::string s, Value & v) else throw; } +} + +void NixRepl::evalString(std::string s, Value & v) +{ + Expr * e = parseString(s); e->eval(*state, *env, v); state->forceValue(v, v.determinePos(noPos)); }