@@ -323,16 +323,14 @@ rec {
323323 else
324324 mergeDefinitions loc opt.type defs';
325325
326− # Check whether the option is defined, and apply the ‘apply’
327− # function to the merged value. This allows options to yield a
328− # value computed from the definitions.
329− value =
330− if !res.isDefined then
331− throw "The option `${showOption loc}' is used but not defined."
332− else if opt ? apply then
333− opt.apply res.mergedValue
334− else
335− res.mergedValue;
326+
327+ # The value with a check that it is defined
328+ valueDefined = if res.isDefined then res.mergedValue else
329+ throw "The option `${showOption loc}' is used but not defined.";
330+
331+ # Apply the 'apply' function to the merged value. This allows options to
332+ # yield a value computed from the definitions
333+ value = if opt ? apply then opt.apply valueDefined else valueDefined;
336334
337335 in opt //
338336 { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;