query
On this page

break

builtins.break

Primop
Docs pulled from | This Revision | about 4 hours ago


Nix manual

Takes 1 arguments

v

In debug mode (enabled using --debugger), pause Nix expression evaluation and enter the REPL. Otherwise, return the argument v.

Noogle detected

Detected Type
break :: a -> a

Implementation

This function is implemented in c++ and is part of the native nix runtime.

src/libexpr/primops.cc:964

static RegisterPrimOp primop_break(
    {.name = "break",
     .args = {"v"},
     .doc = R"(
      In debug mode (enabled using `--debugger`), pause Nix expression evaluation and enter the REPL.
      Otherwise, return the argument `v`.
    )",
     .impl = [](EvalState & state, CallSite callSite, Value * const * args, Value & v) {
         if (state.canDebug()) {
             auto error = Error(
                 ErrorInfo{
                     .level = lvlInfo,
                     .msg = HintFmt("breakpoint reached"),
                     // A non-null but empty pos, so that the debugger doesn't fall back to
                     // the call site (see EvalState::runDebugRepl). The call site is already
                     // shown by the enclosing "while calling a function" trace, so repeating
                     // it on the breakpoint frame would just be noise.
                     .pos = state.positions[noPos],
                 });

             state.runDebugRepl(&error);
         }

         // Return the value we were passed.
         state.forceValue(*args[0], noPos);
         v = *args[0];
     }})