Bug 3766 – pure, nothrow functions should be subtypes of regular functions

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-02-03T13:56:10Z
Last change time
2021-01-24T05:09:14Z
Assigned to
No Owner
Creator
David Simcha

Comments

Comment #0 by dsimcha — 2010-02-03T13:56:10Z
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 by maxhaton — 2021-01-24T05:09:14Z
Has been resolved at some point in the last 10 years (!) https://run.dlang.io/is/bZRTNN