lib/options: Fix mergeEqualOption for singular functions
Previously it would error out for a single function definition
This commit is contained in:
parent
b3810166c7
commit
6e7bc2c6c9
@ -107,6 +107,10 @@ rec {
|
|||||||
/* "Merge" option definitions by checking that they all have the same value. */
|
/* "Merge" option definitions by checking that they all have the same value. */
|
||||||
mergeEqualOption = loc: defs:
|
mergeEqualOption = loc: defs:
|
||||||
if defs == [] then abort "This case should never happen."
|
if defs == [] then abort "This case should never happen."
|
||||||
|
# Return early if we only have one element
|
||||||
|
# This also makes it work for functions, because the foldl' below would try
|
||||||
|
# to compare the first element with itself, which is false for functions
|
||||||
|
else if length defs == 1 then (elemAt defs 0).value
|
||||||
else foldl' (val: def:
|
else foldl' (val: def:
|
||||||
if def.value != val then
|
if def.value != val then
|
||||||
throw "The option `${showOption loc}' has conflicting definitions, in ${showFiles (getFiles defs)}."
|
throw "The option `${showOption loc}' has conflicting definitions, in ${showFiles (getFiles defs)}."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user