D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3766 - pure, nothrow functions should be subtypes of regular functions
Summary: pure, nothrow functions should be subtypes of regular functions
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-03 13:56 UTC by David Simcha
Modified: 2021-01-24 05:09 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description David Simcha 2010-02-03 13:56:10 UTC
void nothrowStuff() nothrow {}
void pureStuff() pure {}
void stuff() {}

auto funcPtr = (0 == 0) ? &stuff : &nothrowStuff;
auto funcPtr2 = (0 == 0) ? &stuff : &pureStuff;

test.d(5): Error: incompatible types for ((& stuff) ? (& nothrowStuff)): 'void function()' and 'void function() nothrow'
test.d(6): Error: incompatible types for ((& stuff) ? (& pureStuff)): 'void function()' and 'void function() pure'

void function() pure and void function() nothrow should be considered subtypes of void function().  A void function() pure or a void function() nothrow simply provides an extra guarantee not present for void function() and thus can be substituted in any context for a void function().
Comment 1 mhh 2021-01-24 05:09:14 UTC
Has been resolved at some point in the last 10 years (!)

https://run.dlang.io/is/bZRTNN