www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23920] New: object.require modifies AA before populating value

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

          Issue ID: 23920
           Summary: object.require modifies AA before populating value
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: dlang-bugzilla thecybershadow.net

////////////////// test.d //////////////////
void main()
{
    int[int] aa;
    try
        aa.require(5, {
            if (true)
                throw new Exception("oops");
            else
                return 1;
        }());
    catch (Exception e) {}
    assert(5 !in aa);
}
////////////////////////////////////////////

This allows bypassing the type system, as it allows the "construction" of types
with ` disable this();`.

--
May 13 2023