Skip to content

[REG 2.111.0] Spurious "expression hasToString!(...) of type void does not have a boolean value" #10764

Closed

Description

@CyberShadow

Looks like there is a regression with writing printable structures.

This code compiles with DMD 2.110.0 but not with 2.111.0:

import std.algorithm.iteration;
import std.array;
import std.format;

struct MapSet(DimName, DimValue)
{
    struct Node
    {
        immutable this(int)
        {
            immutable MapSet[DimValue] children;
            children.byKeyValue.map!(kv => MapSet()).array;
        }

        void toString(void delegate(const(char)[]) sink) const
        {
            const MapSet pair;
            sink.formattedWrite("%s", pair);
        }
    }

    immutable(Node)* root;

    void merge()
    {
        new immutable Node(0);
    }

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

enum VarName { z }

struct MapSetVars()
{
    MapSet!(VarName, int) workingSet;

    void fun()
    {
        workingSet.merge();
    }
}

void funTop()
{
    MapSetVars!() v;
}

Activity

  1. changed the title [-][REG 1.111.0] Spurious "expression `hasToString!(...)` of type `void` does not have a boolean value"[/-] [+][REG 2.111.0] Spurious "expression `hasToString!(...)` of type `void` does not have a boolean value"[/+] on Apr 28, 2025
  2. ibuclaw commented on Apr 28, 2025

    @ibuclaw
    Member

    Duplicate of #10747

  3. added 2 commits that reference this issue on Apr 28, 2025
    950641a
    925ac57
  4. added a commit that references this issue on Apr 28, 2025
    b1d3353
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions