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

Strange semantics when handling empty/null items in equality checks #697

Open
SimonCockx opened this issue Nov 27, 2023 · 0 comments
Open
Labels
bug Something isn't working subject: code generation This issue is about code generation

Comments

@SimonCockx
Copy link
Contributor

Given a list of integers ints, consider the following expression:

ints all = 42

I would expect this expression to be True if and only if "for every item x in the list ints, it holds that x equals 42". However, for an empty list, the behaviour differs from this.

Example:

empty all = 42

Expected: Since empty does not have any items, this should be trivially True.
Actual: False

This is of course a contrived example, but this issue surfaced because of an issue in the CDM having to do with the PriceQuantityTriangulation function. Simplified:

type Foo:
    a int (1..1)

func CheckFoo: // corresponds to the CDM function CashPriceQuantityNoOfUnitsTriangulation
    inputs:
        foo Foo (1..1)
    output:
        success boolean (0..1)
    set success:
        if foo -> a = 42
        then True
        // else empty

func CheckFoos: // corresponds to the CDM function PriceQuantityTriangulation
    inputs:
        foos Foo (0..*)
    output:
        success boolean (0..1)
    set success:
        foos
            extract [
                CheckFoo
            ] all = True

If any of the foos passed to CheckFoos has its attribute a set to 42, this behaves as expected. However, for example the call CheckFoos([Foo {a: 1}, Foo {a: 2}]) results in False, rather than the expected result True.

@SimonCockx SimonCockx added bug Something isn't working subject: code generation This issue is about code generation labels Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working subject: code generation This issue is about code generation
Projects
None yet
Development

No branches or pull requests

1 participant