How to debug broken inference?
Steven Schveighoffer
schveiguy at gmail.com
Fri May 1 21:04:34 UTC 2020
On 5/1/20 4:40 PM, Steven Schveighoffer wrote:
>
> Does anyone have any recommendations of how to approach this? Even if I
> wanted to report a bug, I have no idea why this is happening in this one
> spot. Why can't the compiler *try* @safe and if it doesn't work, just
> decay to @system?
I figured out the issue. It was something very stupid, but probably a
bug in the compiler. In my efforts to avoid bounds checking, I did this:
char[4] buf;
auto slice = buf.ptr[idx .. buf.length];
This compiles if it's tagged @safe, but will not infer safety.
But I don't need to do this trick anyway, it's a static array! So I just
fixed that part of the code.
But I'd say it's a bug in the compiler, it shouldn't accept that as @safe.
Indeed if I just put that in a function, it fails to compile as @safe.
I'll need to dustmite it.
For reference, I used a manual dustmite-like process to narrow down this
function to the part that fails.
-Steve
More information about the Digitalmars-d
mailing list