Skip to content

Draft: Add the support for "and", "or", "not", "not in", "is not"

Akarin requested to merge akarin123/vala:andornot into master

Add the support for "and", "or", "not", "not in", "is not". A draft to address the issue #888.

"! in" and "is !" is intendedly not supported (may need further opinions).

Tested with the code

class Foo {
}

class Bar {
}

void main() {
    string[] foos = {"foo", "bar", "foobar"};
    
    assert ("foo" in foos);
    assert ("barfoo" not in foos);
    assert (("barfoo" not in foos) and ("foo" in foos));
    assert (("barfoo" not in foos) or ("foo" not in foos));
    assert (not ("foobar" not in foos));
    
    Foo foo = new Foo();
    Bar bar = new Bar();
    assert (foo is not Bar and bar is not Foo);
    assert (not (foo is not Foo) or bar is Foo);
}
Edited by Akarin

Merge request reports