www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7803] New: scope(success) in nothrow/ safe functions causes compile errors

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7803

           Summary: scope(success) in nothrow/ safe functions causes
                    compile errors
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: david.eckardt sociomantic.com



05:19:31 PDT ---
Example code:

---
module test;

 safe int f() {
    scope(success) {/* ... */}
    return 3;
}

nothrow int g() {
    scope(success) {/* ... */}
    return 3;
}
---

DMD reports these compile-time errors:

Error: can only catch class objects derived from Exception in  safe code, not
'object.Throwable'

Error: object.Throwable is thrown but not caught test.d(8): Error: function
test.g 'g' is nothrow yet may throw

When using scope(exit) instead, the example code compiles successfully.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 31 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7803


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au



This is happening because

scope(success) { success_clause; }
...

gets transformed into:

try {
  ...
}
catch(Throwable t)
{
   success_clause;
   throw t;
}

Obviously the compiler shouldn't generate an error for code it wrote!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 02 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7803


kekeniro2 yahoo.co.jp changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kekeniro2 yahoo.co.jp
           Severity|minor                       |normal



To make matters worse, the error message misses its location information.

Raised the severity from 'minor'.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 20 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7803


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies gmail.com
            Summary|scope(success) in           |Regression(2.054)
                   |nothrow/ safe functions     |scope(success) in
                   |causes compile errors       |nothrow/ safe functions
                   |                            |causes compile errors
           Severity|normal                      |regression



I caused this by disallowing catch() in  safe code.  Much like issue 6278.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 26 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7803


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com



14:56:44 PDT ---
Is this really a regression? When did it work?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 29 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7803





 Is this really a regression? When did it work?
I haven't tested it, but I assume it is the same cause as issue 6278, and needs the same fix (mark generated catches so they don't get checked for safety. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 29 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7803


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



https://github.com/D-Programming-Language/dmd/pull/1388

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 18 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7803




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/2926c0a493254efeaaff21fe920a00db58f46693
partially fix Issue 7803 - Regression(2.054) scope(success) in nothrow/ safe
functions causes compile errors

https://github.com/D-Programming-Language/dmd/commit/d6a2b1c95d8409e5e2ff0b60de64e2ee25283d96


partially fix Issue 7803 - Regression(2.054) scope(success) in nothrow/ safe
functions causes compile errors

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7803


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



Now original code can be compiled as expected.

Different from bug 6278, the internal catch and re-throwing which used for
scope(success) do not affect to whole code semantics. So I mark this "resolved
fixed".

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 19 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7803





 Now original code can be compiled as expected.
 
 Different from bug 6278, the internal catch and re-throwing which used for
 scope(success) do not affect to whole code semantics. So I mark this "resolved
 fixed".
But, there is still internal semantic inconsistency: - Catching Throwable object in safe code - Re-throwing Throwable object in nothrow code In these points, I couldn't resolve the issues cleanly... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 19 2012