Request for Comment assert(__ctfe)
Steven Schveighoffer
schveiguy at gmail.com
Wed Apr 8 19:01:13 UTC 2020
On 4/8/20 2:53 PM, Jacob Carlborg wrote:
> On 2020-04-07 22:43, Stefan Koch wrote:
>> On Tuesday, 7 April 2020 at 17:52:44 UTC, Jacob Carlborg wrote:
>>>
>>> void foo()
>>> {
>>> assert(__ctfe);
>>> }
>>>
>>> void main() @system
>>> {
>>> try
>>> foo();
>>> catch (AssertError)
>>> {}
>>> }
>>
>> firstly Does anybody actually do this?
>
> Ok, let me tweak the example a bit:
>
> void foo()
> {
> assert(__ctfe);
> }
>
> unittest
> {
> foo();
> }
>
> druntime catches _all_ exceptions:
>
> https://github.com/dlang/druntime/blob/46867186035fdf5ec2596efbb770627518ff0919/src/core/runtime.d#L617
>
>
> Regardless if anyone does it or not, it's still a breaking change. Then
> we can of course argue the impact of the breaking change, how much code
> will actually break.
>
I think it's a breaking change, just like flagging any obvious error
case as a non-compilable error is a breaking change for code that wasn't
aware of the problem.
I'm sure there was lots of code that did something equivalent to this
before it was disallowed:
ref int foo()
{
int x;
return x;
}
That doesn't mean we shouldn't do it.
-Steve
More information about the Digitalmars-d
mailing list