Re: foreach with assoc. array

2023-03-02 Thread Salih Dincer via Digitalmars-d-learn
On Wednesday, 1 March 2023 at 19:05:10 UTC, DLearner wrote: ``` Error: variable `wk_Idx` is shadowing variable `for3.main.wk_Idx` ``` Why is this usage wrong? Or use the `each` template which is almost the same as `foreach` to avoid the shadowing variable issue. ```d import std.algorithm,

Bug in DMD?

2023-03-02 Thread ryuukk_ via Digitalmars-d-learn
Hello, I encountered a weird issue, my program segfault when i feed DMD with my files and static libs It doesn't when i compile with LDC If i split the compile/link in 2 different steps, then all works correctly DMD (1step: ⛔): https://gist.github.com/ryuukk/f0ae2ae0c8980219c04d0c6d86789

Re: Bug in DMD?

2023-03-02 Thread ryuukk_ via Digitalmars-d-learn
It crashes with a weird message, address doesn't match the mangled name: ``C:\dev\kdom\projects\dawn\gl\glad\loader.d`` inside: ``module dawn.gl.glad.loader;`` ![screenshot](https://i.imgur.com/sY2KcgR.png)

Re: Bug in DMD?

2023-03-02 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
There isn't anything we can do without source. But here is what I would do in this situation: 1. Look at the assembly at the point of debug break, from here it should give you hints as to why its trying to write to dawn.assets.Resource init array. 2. Dustmite, so we have something we can work

Re: Bug in DMD?

2023-03-02 Thread ryuukk_ via Digitalmars-d-learn
On Thursday, 2 March 2023 at 21:21:14 UTC, Richard (Rikki) Andrew Cattermole wrote: There isn't anything we can do without source. But here is what I would do in this situation: 1. Look at the assembly at the point of debug break, from here it should give you hints as to why its trying to writ

Re: Bug in DMD?

2023-03-02 Thread ryuukk_ via Digitalmars-d-learn
On Thursday, 2 March 2023 at 21:38:23 UTC, ryuukk_ wrote: On Thursday, 2 March 2023 at 21:21:14 UTC, Richard (Rikki) Andrew Cattermole wrote: There isn't anything we can do without source. But here is what I would do in this situation: 1. Look at the assembly at the point of debug break, from

Re: Bug in DMD?

2023-03-02 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Mar 02, 2023 at 09:55:55PM +, ryuukk_ via Digitalmars-d-learn wrote: > On Thursday, 2 March 2023 at 21:38:23 UTC, ryuukk_ wrote: > > On Thursday, 2 March 2023 at 21:21:14 UTC, Richard (Rikki) Andrew > > Cattermole wrote: [...] > > > 2. Dustmite, so we have something we can work with. >

Re: Bug in DMD?

2023-03-02 Thread ryuukk_ via Digitalmars-d-learn
On Thursday, 2 March 2023 at 22:24:11 UTC, H. S. Teoh wrote: On Thu, Mar 02, 2023 at 09:55:55PM +, ryuukk_ via Digitalmars-d-learn wrote: On Thursday, 2 March 2023 at 21:38:23 UTC, ryuukk_ wrote: > On Thursday, 2 March 2023 at 21:21:14 UTC, Richard (Rikki) > Andrew > Cattermole wrote: [..

Re: Bug in DMD?

2023-03-02 Thread Ali Çehreli via Digitalmars-d-learn
On 3/2/23 15:34, ryuukk_ wrote: > the problem is not that it can run in the background, the problem is > figuring out > > 1. how to install > 2. how to setup > 3. how to run I haven't used it myself but dustmite seems to be integrated into dub. 'dub dustmite <...>' Ali

Re: Bug in DMD?

2023-03-02 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 03/03/2023 12:34 PM, ryuukk_ wrote: 1. how to install Already is. Comes with dmd and ldc. You can also just do ``$ dub run digger -- args``. 2. how to setup > 3. how to run It is a bit of a pain but the basics is you need some sort of compilation command, list of sources and a test to

Re: Bug in DMD?

2023-03-02 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 03/03/2023 10:38 AM, ryuukk_ wrote: On Thursday, 2 March 2023 at 21:21:14 UTC, Richard (Rikki) Andrew Cattermole wrote: There isn't anything we can do without source. But here is what I would do in this situation: 1. Look at the assembly at the point of debug break, from here it should giv

Re: Bug in DMD?

2023-03-02 Thread ryuukk_ via Digitalmars-d-learn
I couldn't figure out dustmite, so i started from 0 and managed to hit something: https://github.com/ryuukk/dmd_bug ``Assertion failed: array index out of bounds, file game\app.d, line 5`` Wich indicates probably TLS problem? This now reminds me of: https://issues.dlang.org/show_bug.cgi?id

Re: Bug in DMD?

2023-03-02 Thread Vladimir Panteleev via Digitalmars-d-learn
On Friday, 3 March 2023 at 01:07:07 UTC, ryuukk_ wrote: I couldn't figure out dustmite, so i started from 0 and managed to hit something: https://github.com/ryuukk/dmd_bug ``Assertion failed: array index out of bounds, file game\app.d, line 5`` Wich indicates probably TLS problem? Yeah...

Re: Bug in DMD?

2023-03-02 Thread ryuukk_ via Digitalmars-d-learn
On Friday, 3 March 2023 at 01:11:06 UTC, Vladimir Panteleev wrote: On Friday, 3 March 2023 at 01:07:07 UTC, ryuukk_ wrote: I couldn't figure out dustmite, so i started from 0 and managed to hit something: https://github.com/ryuukk/dmd_bug ``Assertion failed: array index out of bounds, file g

Re: Bug in DMD?

2023-03-02 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
This works: ```d extern(C) void main() { Stuff[5] temp = [ Stuff(), Stuff(), Stuff(), Stuff(), Stuff(), ]; stuffs = temp[]; stuffs[0].do_something(); } ``` ```d Stuff[] stuffs; ``` The problem here is dmd isn't initializing TLS with a valu

Re: Bug in DMD?

2023-03-02 Thread ryuukk_ via Digitalmars-d-learn
On Friday, 3 March 2023 at 01:24:42 UTC, Richard (Rikki) Andrew Cattermole wrote: This works: ```d extern(C) void main() { Stuff[5] temp = [ Stuff(), Stuff(), Stuff(), Stuff(), Stuff(), ]; stuffs = temp[]; stuffs[0].do_something(); } ``` `

Re: Bug in DMD?

2023-03-02 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 03/03/2023 2:33 PM, ryuukk_ wrote: So it is a DMD bug? Yes and thanks to you I can now say that we can absolutely get rid of DllMain requirement for DLLs!

Re: Bug in DMD?

2023-03-02 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
I added a note here: https://issues.dlang.org/show_bug.cgi?id=20737

Re: Bug in DMD?

2023-03-02 Thread Vladimir Panteleev via Digitalmars-d-learn
On Friday, 3 March 2023 at 01:21:52 UTC, ryuukk_ wrote: I have some questions: 1. why does it work with LDC? 2. why does it work with DMD when build/link in 2 step? 3. why it doesn't work when DMD is invoked once for build/link I think these are probably coincidences and the answer can be sum

Re: Bug in DMD?

2023-03-02 Thread ryuukk_ via Digitalmars-d-learn
On Friday, 3 March 2023 at 01:37:42 UTC, Richard (Rikki) Andrew Cattermole wrote: On 03/03/2023 2:33 PM, ryuukk_ wrote: So it is a DMD bug? Yes and thanks to you I can now say that we can absolutely get rid of DllMain requirement for DLLs! glad the outcome is positive, and i apologies about

Some questions with D and webassembly

2023-03-02 Thread TheZipCreator via Digitalmars-d-learn
In webassembly, there's a type called `externref`, which opaquely represents a javascript object. So, you could do this for example, with this javascript: ```js class Foo { constructor(x) { this.x = x; } } const imports = { env: { fooNew:

Desiring bool any_key_pressed()

2023-03-02 Thread Daren Scot Wilson via Digitalmars-d-learn
Here is a very simple version of the program I'm working on. Is there a way to write is_any_key_pressed() that doesn't block, doesn't require the Enter key, and doesn't require dragging in any complex libraries or dealing with low-level stuff like ioctl()? Is there nothing in Phobos that provi