Bug 21528 – Implement contracts without implementation generally

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-01-08T03:14:18Z
Last change time
2024-12-13T19:13:49Z
Assigned to
No Owner
Creator
timon.gehr
Moved to GitHub: dmd#19848 →

Comments

Comment #0 by timon.gehr — 2021-01-08T03:14:18Z
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.
Comment #1 by robert.schadek — 2024-12-13T19:13:49Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19848 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB