www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21528] New: Implement contracts without implementation

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

          Issue ID: 21528
           Summary: Implement contracts without implementation generally
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: timon.gehr gmx.ch

I'm opening this because it appears issue 6549 has been closed due to a more
specific interpretation than I had intended. (But the fix is already a win.)

Currently, code like the following is rejected:

int foo(int x)
  in{assert(x<0);}
  out(result){assert(result>0);}

tt.di(2): Error: function `tt.foo` `in` and `out` contracts can only appear
without a body when they are virtual interface functions or abstract

This is still an arbitrary restriction, because contracts logically belong to
the function declaration. (You can interpret the contracts as a restriction of
the argument/return types, so it makes little sense to allow argument/return
types but not contracts.)

Such code should be accepted. This may require changing name mangling so it
contains a hash of the contracts.

--
Jan 07