Skip to content

Commit c6fba6b

Browse files
committed
Widen ValidationError :key type to allow lists
The struct already stores a list of atoms for the "unknown options" error (lib/nimble_options.ex:524 passes a list of keys; test "unknown options" asserts `key: [:not_an_option1, :not_an_option2]`). The @type for the field said `atom()` only, so the new set-theoretic checker in elixir-lang/elixir#15366 flags every caller of error_tuple at that site and cascades into every package that depends on nimble_options. Widening to `atom() | [atom()]` matches actual runtime behavior. Doc updated to call out the multi-key case. No code change, no test change. Signed-off-by: Chris Garvis <cgarvis@gmail.com>
1 parent f16af25 commit c6fba6b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

lib/nimble_options/validation_error.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ defmodule NimbleOptions.ValidationError do
99
"""
1010

1111
@type t() :: %__MODULE__{
12-
key: atom(),
12+
key: atom() | [atom()],
1313
keys_path: [atom()],
1414
redact: boolean,
1515
value: term()
@@ -21,7 +21,9 @@ defmodule NimbleOptions.ValidationError do
2121
Only the following documented fields are considered public. All other fields are
2222
considered private and should not be referenced:
2323
24-
* `:key` (`t:atom/0`) - The key that did not successfully validate.
24+
* `:key` (`t:atom/0` or list of `t:atom/0`) - The key that did not successfully
25+
validate. When several keys are involved in the same error (for example,
26+
unknown options reported as a group), this is the list of those keys.
2527
2628
* `:keys_path` (list of `t:atom/0`) - If the key is nested, this is the path to the key.
2729

0 commit comments

Comments
 (0)