On Saturday, 23 March 2024 at 23:59:18 UTC, Liam McGillivray
wrote:
I replaced `destroy(unit)` with `map.deleteUnit(unit)`, and it
solved the problem.
Nevermind. It turns out this was because the call to the Unit
destructor was missing in `Map.deleteUnit`. The segfault happens
whenever a unit
On Saturday, 23 March 2024 at 04:32:29 UTC, harakim wrote:
This comment points to a symptom of the circular
dependency: //Always set `destroy` to false when calling from
the Unit destructor, to avoid an infinite loop.
I was just doing some work on the AI system, and I had a segfault
every time
```d
@safe:
void foo ()
{
import std.typecons : SafeRefCounted;
SafeRefCounted!int s;
}
unittest {
import std.exception : assertNotThrown;
assertNotThrown (foo);
}
```
```
$ dmd -unittest -main -run sr.d
sr.d(6): Error: `@safe` function `sr.foo` cannot call `@system`
destructor `s
On Saturday, 23 March 2024 at 04:32:29 UTC, harakim wrote:
You should engineer the system in a way that makes sense to
you. The currency of finishing programs is motivation and that
comes from success and believing you will succeed. If you're
implementing XYZ pattern from someone else, if you d
On Saturday, 23 March 2024 at 21:53:43 UTC, Jonathan M Davis
wrote:
Yes, it's a bug. It's a clear violation of the type system if a
non-mutable variable is ever given a value more than once. It
should be initialized, and then it should be treated as illegal
to ever assign to it - or to do anyth
On Saturday, March 23, 2024 3:23:23 PM MDT Nick Treleaven via Digitalmars-d-
learn wrote:
> I've not used static constructors before, but it seems like the
> following should not be allowed:
>
> ```d
> import std.stdio;
>
> immutable int x;
>
> @safe shared static this()
> {
> x.writeln(); //
I've not used static constructors before, but it seems like the
following should not be allowed:
```d
import std.stdio;
immutable int x;
@safe shared static this()
{
x.writeln(); // 0
x = 5;
x.writeln(); // 5
x = 6;
x++;
assert(x == 7);
}
```
Should I file a bug to requ
On Saturday, 23 March 2024 at 19:30:29 UTC, Menjanahary R. R.
wrote:
for (T candidate = T(5); candidate * candidate <= n;
candidate += T(6)) {
When T is `const int`, the above code declares and initializes a
constant variable:
```d
const int candidate = const int(5);
```
Then, at the end
On Saturday, March 23, 2024 1:30:29 PM MDT Menjanahary R. R. via Digitalmars-
d-learn wrote:
> The next code works as is but ...
>
> ```
> import std.stdio;
> import std.traits;
>
> bool isPrime(T)(T n) if (isIntegral!T) {
> if (n <= T(3)) return n > T(1);
>
> if (n % T(2) == T(0) || n %
The next code works as is but ...
```
import std.stdio;
import std.traits;
bool isPrime(T)(T n) if (isIntegral!T) {
if (n <= T(3)) return n > T(1);
if (n % T(2) == T(0) || n % T(3) == T(0)) return false;
for (T candidate = T(5); candidate * candidate <= n;
candidate += T(6)) {
On Saturday, 23 March 2024 at 11:04:04 UTC, Dmitry Olshansky
wrote:
On Saturday, 23 March 2024 at 09:08:45 UTC, Per Nordlöw wrote:
Is there a reason why
```d
class Base {}
class Derived : Base {}
@safe pure nothrow unittest {
Base b;
Derived d;
b = d; // pass
B
On Saturday, 23 March 2024 at 09:08:45 UTC, Per Nordlöw wrote:
Is there a reason why
```d
class Base {}
class Derived : Base {}
@safe pure nothrow unittest {
Base b;
Derived d;
b = d; // pass
Base[] bs;
Derived[] ds;
bs ~= ds; // pass
bs
Is there a reason why
```d
class Base {}
class Derived : Base {}
@safe pure nothrow unittest {
Base b;
Derived d;
b = d; // pass
Base[] bs;
Derived[] ds;
bs ~= ds; // pass
bs = ds; // fail [1], should pass
bs = cast(Base[])ds; // f
13 matches
Mail list logo