Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support more than 2 logicals in XOR core function #2396

Closed
DFog14 opened this issue Feb 8, 2023 · 1 comment · Fixed by #2614 · May be fixed by #2616
Closed

Support more than 2 logicals in XOR core function #2396

DFog14 opened this issue Feb 8, 2023 · 1 comment · Fixed by #2614 · May be fixed by #2616
Labels
enhancement New feature or request

Comments

@DFog14
Copy link

DFog14 commented Feb 8, 2023

Describe the bug
In Spectral5.9.2, the core XOR function could accept more than 2 items in its properties' list. In Spectral6+, the core XOR function only appears to support two logical.

To Reproduce
Create a ruleset that leverages the core XOR function:

each-component-property-must-contain-only-one:
given: $.components...properties.*
recommended: true
severity: warn
then:
function: xor
functionOptions:
properties:
- type
- oneOf
- $ref

This rule running on 5.9.2 will work with no issue
This rule running on 6+ will result in the following error:
Error #1: "xor" and its "properties" option support 2-item tuples, i.e. ["id", "name"]

Expected behavior
The XOR function will behave in the way that it always has, allowing more than just 2 logicals.

Additional context
I understand that from an electrical perspective, an XOR gate only takes two inputs, but XOR functionality can support an unlimited number of inputs in practical use. If this was an intended behavior change, then so be it, it just seems like an odd decision to make as it breaks compatibility and the docs page still lists the function as supporting a list of logicals.

Judging by commit histories, it looks like the xor function was completely redesigned in 6.0.0alpha1, this redesign seems to have limited it to two logicals

@P0lip
Copy link
Contributor

P0lip commented Feb 23, 2023

The function was never intended to take more than 2 logical.
You can see the code we have in 5.9.2 here and see that we have a check for properties.length !== 2.
In other words, what currently happens in v5.x is the function does nothing if you specify more than 2 logicals.

We could possibly make it take more than 2 logicals tho.
I'll keep that ticket around.

@P0lip P0lip changed the title XOR core function no longer supports more than 2 logicals Support more than 2 logicals in XOR core function Feb 23, 2023
@P0lip P0lip added the enhancement New feature or request label Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants