[Issue 21244] New: Error: expression `hasToString!(..., char)` of type `void` does not have a boolean value

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Sep 14 02:26:22 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=21244

          Issue ID: 21244
           Summary: Error: expression `hasToString!(..., char)` of type
                    `void` does not have a boolean value
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dlang-bugzilla at thecybershadow.net

Looks like a DMD problem with recursive templated types.

Partial reduction:

//////////////////////// test.d ////////////////////////
import std.format;
import std.stdio;

struct M(_)
{
    struct N
    {
        M* next;

        void print()
        {
            next.print();
        }

        void toString(void delegate(const(char)[]) sink)
        {
            if (next) sink.formattedWrite("%s", *next);
        }
    }

    N* root;

    void print()
    {
        writeln(this);
    }

    void toString(void delegate(const(char)[]) sink)
    {
        if (root) sink.formattedWrite("%s", *root);
    }
}

M!int x;
////////////////////////////////////////////////////////

Yields a wall of errors starting with:

.../std/format.d(4420): Error: expression hasToString!(M!int, char) of type
void does not have a boolean value

--


More information about the Digitalmars-d-bugs mailing list