Re: static assert not printing out along the error diagnostic

2021-07-14 Thread someone via Digitalmars-d-learn
On Wednesday, 14 July 2021 at 23:44:18 UTC, jfondren wrote: On Wednesday, 14 July 2021 at 22:59:38 UTC, someone wrote: [...] so, these lines: ```d stringUGC32 lugcSequence3 = stringUGC32(cast(char) 'x'); stringUGC32 lugcSequence4 = stringUGC32(1); ``` which call stringUGC32, an

Re: static assert not printing out along the error diagnostic

2021-07-14 Thread jfondren via Digitalmars-d-learn
On Wednesday, 14 July 2021 at 22:59:38 UTC, someone wrote: Please, go to the bottom of the unittest block and uncomment one of those lines (DMD version here is DMD64 D Compiler v2.096.1): so, these lines: ```d stringUGC32 lugcSequence3 = stringUGC32(cast(char) 'x'); stringUGC32

Re: static assert not printing out along the error diagnostic

2021-07-14 Thread someone via Digitalmars-d-learn
On Wednesday, 14 July 2021 at 19:00:08 UTC, jfondren wrote: On Wednesday, 14 July 2021 at 18:04:44 UTC, someone wrote: On Wednesday, 14 July 2021 at 06:28:37 UTC, jfondren wrote: alternate 1: - pull tests out into a named enum template, like std.traits - always static assert enum, rather than

Re: static assert not printing out along the error diagnostic

2021-07-14 Thread jfondren via Digitalmars-d-learn
On Wednesday, 14 July 2021 at 18:04:44 UTC, someone wrote: On Wednesday, 14 July 2021 at 06:28:37 UTC, jfondren wrote: alternate 1: - pull tests out into a named enum template, like std.traits - always static assert enum, rather than conditionally asserting false - always have the rest of

Re: static assert not printing out along the error diagnostic

2021-07-14 Thread someone via Digitalmars-d-learn
On Wednesday, 14 July 2021 at 06:28:37 UTC, jfondren wrote: alternate 1: - pull tests out into a named enum template, like std.traits - always static assert enum, rather than conditionally asserting false - always have the rest of the code ```d enum isString(T) = is(T == string) || is(T ==

Re: static assert not printing out along the error diagnostic

2021-07-14 Thread jfondren via Digitalmars-d-learn
On Wednesday, 14 July 2021 at 03:06:06 UTC, someone wrote: in main() ... so then I went to the D docs and to Ali's book afterward and there I tested his example to same results. The current behavior seems like it could be taken for a bug, or at least room for improvement in letting static

Re: static assert not printing out along the error diagnostic

2021-07-14 Thread SealabJaster via Digitalmars-d-learn
On Wednesday, 14 July 2021 at 05:59:19 UTC, SealabJaster wrote: I've ran into this rarely. At a guess, it seems something triggers the compiler to either evaluate something in non-lexical order; doesn't realise it needs to error out at the static assert instead of doing it later, or maybe it

Re: static assert not printing out along the error diagnostic

2021-07-14 Thread SealabJaster via Digitalmars-d-learn
On Wednesday, 14 July 2021 at 03:06:06 UTC, someone wrote: ... I've ran into this rarely. At a guess, it seems something triggers the compiler to either evaluate something in non-lexical order; doesn't realise it needs to error out at the static assert instead of doing it later, or maybe it

Re: static assert not printing out along the error diagnostic

2021-07-13 Thread someone via Digitalmars-d-learn
On Wednesday, 14 July 2021 at 02:42:21 UTC, Paul Backus wrote: Weirdly, adding a dummy `ResultType` declaration to the `else` branch makes the assert message show up: My code is like following: ```d public struct gudtUGC(typeStringUTF) { static if (! (is (typeStringUTF == string) || is

Re: static assert not printing out along the error diagnostic

2021-07-13 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 14 July 2021 at 02:28:07 UTC, someone wrote: If I add in main(): ```d auto g = MyType!string(); g.doWork(); ``` I get: ...: Error: undefined identifier `ResultType` ...: Error: template instance `...MyType!string` error instantiating But nothing like: ```d T.stringof

static assert not printing out along the error diagnostic

2021-07-13 Thread someone via Digitalmars-d-learn
The following example is from Ali's book @ http://ddili.org/ders/d.en/cond_comp.html: ```d import std.stdio; struct MyType(T) { static if (is (T == float)) { alias ResultType = double; } else static if (is (T == double)) { alias ResultType = real; } else {