finos/rune-dsl

Strange semantics when handling `empty`/`null` items in equality checks

SimonCockx opened this issue · 0 comments

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.