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
8 changes: 7 additions & 1 deletion src/libcmd/repl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,13 @@ ExprAttrs * NixRepl::parseReplBindings(std::string s)
// Try parsing as bindings
try {
return state->parseReplBindings(s, basePath, staticEnv);
} catch (ParseError &) {
} catch (ParseError & e) {
// If the input is incomplete (e.g. `a = {` without closing `}`),
// signal the main loop to prompt for continuation instead of falling
// through to expression evaluation (which would produce a confusing
// "unexpected '='" error).
if (isIncompleteInput(e))
throw IncompleteReplExpr(e.msg());
}

// Try with semicolon appended (for `inherit foo` shorthand)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Nix <nix version>
Type :? for help.

nix-repl> a = {
> b = 1;
> }

nix-repl> a
{ b = 1; }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# COM: Multi-line attribute set in binding should trigger continuation (issue #16310)
a = {
b = 1;
}
a
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Nix <nix version>
Type :? for help.

nix-repl> {
> x = 1;
> }
{ x = 1; }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# COM: Multi-line attribute set expression (not binding) should still trigger continuation (issue #16310)
{
x = 1;
}