[Issue 20432] New: assert() and in() don't support tuple expressions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 5 14:53:51 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=20432

          Issue ID: 20432
           Summary: assert() and in() don't support tuple expressions
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: default_357-line at yahoo.de

Consider the following code:

// this works
assertThrown!AssertError({
    assert(false, "hello world");
}(), "hello world");

// this doesn't work
struct S
{
    bool b;
    string s;
}
assertThrown!AssertError({
    assert(S(false, "hello world").tupleof);
}(), "hello world");

Likewise for in().

This is annoying, because it prevents writing functions that either return
success or an error value, or rather forces to call them twice.

--


More information about the Digitalmars-d-bugs mailing list