Re: final switch problem

2020-06-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, June 13, 2020 10:22:39 AM MDT John Chapman via Digitalmars-d- learn wrote: > On Saturday, 13 June 2020 at 15:33:55 UTC, Boris Carvajal wrote: > > On Saturday, 13 June 2020 at 09:02:21 UTC, John Chapman wrote: > >> Is this a bug or have I made a mistake? This worked a few days > >> ago

Re: final switch problem

2020-06-13 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Jun 13, 2020 at 09:02:21AM +, John Chapman via Digitalmars-d-learn wrote: [...] > module test; > > import std.uni; > > enum Cheese { cheddar, edam } > > void test(Cheese cheese) { > final switch (cheese) { > case Cheese.cheddar: break; > case Cheese.edam: break; > } > } >

Re: Why is it possible to call non-const member functions of rvalues but a compile error to modify members or rvalues directly?

2020-06-13 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 13 June 2020 at 11:26:58 UTC, Johannes Loher wrote: Why is it a compile error to set `_a` directly but calling `a` just works fine? If we prevent modifying members of rvalues directly, I would also expect calling non-const member functions of rvalues to be prevented. 1)

Weird behavior with UDAs

2020-06-13 Thread realhet via Digitalmars-d-learn
Hello, I have a problem I can't even understand with the code below: https://run.dlang.io/is/7yXAEA import std.stdio, std.range, std.algorithm, std.traits, std.meta; struct UNIFORM{ string name; } struct A{ int i1; @UNIFORM() int i2; @UNIFORM("fuzz") int i3; @UNIFORM int i4;

Re: Weird behavior with UDAs

2020-06-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 13 June 2020 at 12:55:36 UTC, realhet wrote: My first question is, how to avoid that error with A.i4? Why is there a difference between @UNIFORM and @UNIFORM(), do the first returns a type and the later returns a value? Basically yeah. a UDA in D is just whatever you write gets

Re: Weird behavior with UDAs

2020-06-13 Thread realhet via Digitalmars-d-learn
On Saturday, 13 June 2020 at 12:55:36 UTC, realhet wrote: Hello, I have a problem I can't even understand with the code For the first I realized that an UDA can be a type too, and come up with this: template getUDA(alias a, U){ enum u = q{ getUDAs!(a, U)[$-1] }; static if(hasUDA!(a,

Re: final switch problem

2020-06-13 Thread Boris Carvajal via Digitalmars-d-learn
On Saturday, 13 June 2020 at 09:02:21 UTC, John Chapman wrote: Is this a bug or have I made a mistake? This worked a few days ago and I haven't changed my setup since then. https://issues.dlang.org/show_bug.cgi?id=19548 Your code triggers it by using "-debug" option on https://run.dlang.io/

final switch problem

2020-06-13 Thread John Chapman via Digitalmars-d-learn
If I use a final switch and import std.uni (or any other module that imports it, such as std.string), I'm getting unresolved external symbol errors with DMD 2.092. This code triggers the issue: --- module test; import std.uni; enum Cheese { cheddar, edam } void test(Cheese cheese) {

Re: Finding out ref-ness of the return of an auto ref function

2020-06-13 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 13 June 2020 at 09:13:36 UTC, Arafel wrote: If, however, you're wrapping a function template, however, you won't know until you actually instantiate it, which is basically going back to Paul Backus' solution. So the compiler doesn't always have all the information :) Well, the

Re: Finding out ref-ness of the return of an auto ref function

2020-06-13 Thread Arafel via Digitalmars-d-learn
On 12/6/20 20:34, Stanislav Blinov wrote: On Friday, 12 June 2020 at 17:50:43 UTC, Arafel wrote: All in all, I still think something like `__traits(isRef,return)` would still be worth adding! After all the compiler already has all the information, so it's just about exposing it. I'm trying to

Re: Finding the file and unittest that triggers an ICE during dub project build only when unittests are enabled

2020-06-13 Thread Per Nordlöw via Digitalmars-d-learn
On Friday, 12 June 2020 at 20:12:46 UTC, Luis wrote: Fails with dub test ? Yes. In the same way.

Re: Finding the file and unittest that triggers an ICE during dub project build only when unittests are enabled

2020-06-13 Thread Per Nordlöw via Digitalmars-d-learn
On Friday, 12 June 2020 at 21:54:57 UTC, H. S. Teoh wrote: On Fri, Jun 12, 2020 at 09:29:06PM +, MoonlightSentinel via Digitalmars-d-learn wrote: On Friday, 12 June 2020 at 18:18:25 UTC, Per Nordlöw wrote: > How do I most easily track down which unittest in which file > that causes the

Why is it possible to call non-const member functions of rvalues but a compile error to modify members or rvalues directly?

2020-06-13 Thread Johannes Loher via Digitalmars-d-learn
Consider the following example: ``` struct A { auto a(int _a) { return this._a = _a; } int _a = 0; } void main() { static assert(!__traits(compiles, { A()._a = 2; })); static assert(__traits(compiles, { A().a(2); })); } ``` (https://run.dlang.io/is/GkmpA8) Why

Re: final switch problem

2020-06-13 Thread Ali Çehreli via Digitalmars-d-learn
On 6/13/20 9:22 AM, John Chapman wrote: Hmm, compiling with -release makes it work. Not a huge issue, I'll just avoid final switches in debug mode until it's fixed. Thanks. Apparently, it's a known issue: https://issues.dlang.org/show_bug.cgi?id=19548 Ali

Re: final switch problem

2020-06-13 Thread John Chapman via Digitalmars-d-learn
On Saturday, 13 June 2020 at 15:33:55 UTC, Boris Carvajal wrote: On Saturday, 13 June 2020 at 09:02:21 UTC, John Chapman wrote: Is this a bug or have I made a mistake? This worked a few days ago and I haven't changed my setup since then. https://issues.dlang.org/show_bug.cgi?id=19548 Your

Re: Weird behavior with UDAs

2020-06-13 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 13 June 2020 at 13:08:29 UTC, realhet wrote: How can be a string represented with 'null' by default instead on `""`. Unless I state it explicitly with name="" ? o.O Because string is simply `alias string = immutable(char)[]`, and default initializer for arrays is null.

vibe / CTRL+C not terminating server

2020-06-13 Thread Robert M. Münch via Digitalmars-d-learn
After a CTRL+C I still have the server process running on OSX. Any idea? [main() INF] Listening for requests on http://[::1]:8080/ [main() INF] Listening for requests on http://127.0.0.1:8080/ [main() INF] Please open http://127.0.0.1:8080/ in your browser. ^C [main() INF]

Re: vibe / CTRL+C not terminating server

2020-06-13 Thread Daniel Kozak via Digitalmars-d-learn
On Sat, Jun 13, 2020 at 9:20 PM Robert M. Münch via Digitalmars-d-learn wrote: > > After a CTRL+C I still have the server process running on OSX. Any idea? > > [main() INF] Listening for requests on http://[::1]:8080/ > [main() INF] Listening for requests on http://127.0.0.1:8080/ >

Re: DUB project type support for Emacs Projectile

2020-06-13 Thread Jean-Louis Leroy via Digitalmars-d-learn
On Monday, 18 November 2019 at 23:06:14 UTC, Per Nordlöw wrote: Have anybody written support for DUB project types in Emacs' projectile? See: https://www.projectile.mx/en/latest/projects/#adding-custom-project-types Normally it should be as easy as this: (projectile-register-project-type

Initializing an associative array of struct

2020-06-13 Thread Denis via Digitalmars-d-learn
Hi, I'm trying to combine a couple of general types (associative array, struct) in a compound data structure, but without success. Here is what I'm trying to achieve: "param" is a string variable "parameters[param].id" is an integer value "parameters[param].value" is a string