Repository: spack/spack

Issue:
Conditional variants: first value can't be conditional
### Steps to reproduce

This took a while to track down, but it's easy to reproduce. First, create a new package:
```console
$ spack create
```
Then, add the example conditional from [the docs](https://spack.readthedocs.io/en/latest/packaging_guide.html#conditional-possible-values):
```python
variant(
    'cxxstd', default='98',
    values=(
        '98', '11', '14',
        # C++17 is not supported by Boost < 1.63.0.
        conditional('17', when='@1.63.0:'),
        # C++20/2a is not support by Boost < 1.73.0
        conditional('2a', '2b', when='@1.73.0:'),
    ),
    multi=False,
    description='Use the specified C++ standard when building.',
)
```
If you run:
```console
$ spack audit packages example
```
you'll see that there are some warnings about boilerplate code, but no errors. However, if you modify the list of conditional values such that the first value is conditional:
```python
variant(
    'cxxstd', default='98',
    values=(
        # C++17 is not supported by Boost < 1.63.0.
        conditional('17', when='@1.63.0:'),
        # C++20/2a is not support by Boost < 1.73.0
        conditional('2a', '2b', when='@1.73.0:'),
        '98', '11', '14',
    ),
    multi=False,
    description='Use the specified C++ standard when building.',
)
```
you will discover an error.

### Error message

```console
$ spack --debug audit packages example
Traceback (most recent call last):
  File "/Users/ajstewart/spack/bin/spack", line 100, in <module>
    sys.exit(spack.main.main())
  File "/Users/ajstewart/spack/lib/spack/spack/main.py", line 977, in main
    return _main(argv)
  File "/Users/ajstewart/spack/lib/spack/spack/main.py", line 932, in _main
    return finish_parse_and_run(parser, cmd_name, env_format_error)
  File "/Users/ajstewart/spack/lib/spack/spack/main.py", line 960, in finish_parse_and_run
    return _invoke_command(command, parser, args, unknown)
  File "/Users/ajstewart/spack/lib/spack/spack/main.py", line 609, in _invoke_command
    return_val = command(parser, args)
  File "/Users/ajstewart/spack/lib/spack/spack/cmd/audit.py", line 86, in audit
    subcommands[args.subcommand](parser, args)
  File "/Users/ajstewart/spack/lib/spack/spack/cmd/audit.py", line 51, in packages
    reports = spack.audit.run_group(args.subcommand, pkgs=pkgs)
  File "/Users/ajstewart/spack/lib/spack/spack/audit.py", line 147, in run_group
    errors = run_check(check, **kwargs)
  File "/Users/ajstewart/spack/lib/spack/spack/audit.py", line 162, in run_check
    return CALLBACKS[tag].run(**kwargs)
  File "/Users/ajstewart/spack/lib/spack/spack/audit.py", line 130, in run
    errors.extend(fn(**kwargs))
  File "/Users/ajstewart/spack/lib/spack/spack/audit.py", line 663, in _ensure_variant_defaults_are_parsable
    vspec = variant.make_default()
  File "/Users/ajstewart/spack/lib/spack/spack/variant.py", line 160, in make_default
    return self.make_variant(self.default)
  File "/Users/ajstewart/spack/lib/spack/spack/variant.py", line 173, in make_variant
    return self.variant_cls(self.name, value)
  File "/Users/ajstewart/spack/lib/spack/spack/variant.py", line 180, in variant_cls
    elif self.values == (True, False):
  File "/Users/ajstewart/spack/lib/spack/spack/variant.py", line 891, in __eq__
    return self.value == other.value
AttributeError: 'bool' object has no attribute 'value'
```

### Information on your system

* **Spack:** 0.19.0.dev0 (9e0755ca3a125f6360ea84223630a05363536101)
* **Python:** 3.9.13
* **Platform:** darwin-monterey-m1
* **Concretizer:** clingo


### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have searched the issues of this repo and believe this is not a duplicate
- [X] I have run the failing commands in debug mode and reported the output


Discussion:

Resolving patch:
diff --git a/lib/spack/spack/variant.py b/lib/spack/spack/variant.py
--- a/lib/spack/spack/variant.py
+++ b/lib/spack/spack/variant.py
@@ -886,7 +886,7 @@ def __hash__(self):
         return hash(self.value)
 
     def __eq__(self, other):
-        if isinstance(other, six.string_types):
+        if isinstance(other, (six.string_types, bool)):
             return self.value == other
         return self.value == other.value
 


Test patch:
diff --git a/lib/spack/spack/test/variant.py b/lib/spack/spack/test/variant.py
--- a/lib/spack/spack/test/variant.py
+++ b/lib/spack/spack/test/variant.py
@@ -2,13 +2,12 @@
 # Spack Project Developers. See the top-level COPYRIGHT file for details.
 #
 # SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
-
 import numbers
 
 import pytest
 
 import spack.error
+import spack.variant
 from spack.variant import (
     BoolValuedVariant,
     DuplicateVariantError,
@@ -737,3 +736,11 @@ def test_disjoint_set_fluent_methods():
         assert "none" not in d
         assert "none" not in [x for x in d]
         assert "none" not in d.feature_values
+
+
+@pytest.mark.regression("32694")
+@pytest.mark.parametrize("other", [True, False])
+def test_conditional_value_comparable_to_bool(other):
+    value = spack.variant.Value("98", when="@1.0")
+    comparison = value == other
+    assert comparison is False