On Sunday, 29 December 2024 at 12:22:42 UTC, Andrej Mitrovic
wrote:
On Thursday, 28 November 2024 at 07:08:29 UTC, Walter Bright
wrote:
https://github.com/dlang/dmd/pull/17044
It's enabled with -preview=safer
I think this is going to still cause issues with dependencies,
which might just be a dub problem but I'm not sure.
For example I've tried to add `dflags `-preview=safer` to my
dub.sdl and now I get errors from 3rd party libraries:
```
lib\bindbc-glfw\source\bindbc\glfw\binddynamic.d(326,24):
Error: `name.ptr` cannot be used in `@safe` code, use
`&name[0]` instead
lib\bindbc-glfw\source\bindbc\glfw\binddynamic.d(342,33):
Error: `@safe` function `loadGLFW` cannot access `__gshared`
data `glfwInit`
lib\bindbc-glfw\source\bindbc\glfw\binddynamic.d(342,20):
Error: cast from `extern (C) int function() nothrow @nogc*` to
`void**` not allowed in safe code
lib\bindbc-glfw\source\bindbc\glfw\binddynamic.d(343,33):
Error: `@safe` function `loadGLFW` cannot access `__gshared`
data `glfwTerminate`
lib\bindbc-glfw\source\bindbc\glfw\binddynamic.d(343,20):
Error: cast from `extern (C) void function() nothrow @nogc*` to
`void**` not allowed in safe code
lib\bindbc-glfw\source\bindbc\glfw\binddynamic.d(344,33):
Error: `@safe` function `loadGLFW` cannot access `__gshared`
data `glfwGetVersion`
```
Still it's a great step forward, thanks for your work~
So essentially this might even work fine if I used .di
dependencies instead of .d, as that would hide the implementation
code from the compiler so it couldn't do any analysis (never mind
that nobody uses .di).
But with templates it wouldn't be a workable solution anyway.
I don't see how anyone is going to try and use -preview=safer
*unless* they are able to use other libraries which are ready for
this switch. But most libraries will not be ready for it.
Therefore people who use libraries will not be able to enable
this switch.
Therefore this is a catch-22 problem.
I don't know if it's possible to limit certain switches to
particular packages, but I would prefer if I could enable the
`-preview=safer` switch *only* for code within `./src`.
In other words code I directly have control over. Is that
possible with dub..?