[Issue 8651] New: Slice op Slice throws exceptions (not errors), and nothrow

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 13 08:42:51 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8651

           Summary: Slice op Slice throws exceptions (not errors), and
                    nothrow
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: monarchdodra at gmail.com


--- Comment #0 from monarchdodra at gmail.com 2012-09-13 08:42:59 PDT ---
2 related problems:

First
--------
import std.stdio;
void main()
{
  try
  {
    int[] b = new int[](10);
    b[] = 5;
    b[0..6] = b[4..10];
  }
  catch(Exception e)
  {
    writeln(e);
  }
  writeln("finish");
}
--------
The built-in range assign will throw an Exception when it fails. This should be
an Error.

Second
--------
nothrow void foo(int[] a)
{
  a[] = a[];
}

nothrow void bar(int[] a)
{
  a[] += a[];
}
--------
_arraySliceSliceAddass_i is not nothrow
function main.bar 'bar' is nothrow yet may throw
--------
This is doubly problematic:
First, these methods should throw Errors, so the code should compile.
Two, ironically, []+=[] currently doesn't throw anything, and []=[] throws an
exception, yet it is the []+=[] version that doesn't compile.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list