Skip to content

Inconsistent output for enum value when calling "text" vs "to!string" #9817

Open
@dlangBugzillaToGithub

Description

@dlangBugzillaToGithub

apz28 reported this on 2021-02-15T21:44:23Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=21639

Description

import std.stdio;
import std.conv : text, to;

enum I : int
{
    x10 = 10,
}

enum C : char
{
    xChar = '%',
}

enum S : string
{
    xString = "a string",
}

void main()
{
    writeln(to!string(I.x10)); // x10
    writeln(to!string(C.xChar)); // xChar
    writeln(to!string(S.xString)); // xString
    writeln(text(I.x10, " ", C.xChar, " ", S.xString)); // x10 % xString
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions