Skip to content

Constness and immutability of AA keys is handled unflexibly #23320

Description

@0xEAB
/opt/ldc2-1.42.0/bin/../import/core/internal/newaa.d(172): Error: cannot implicitly convert expression `key` of type `const(char[])` to `string`
        entry.key = key;

But if key were const(char)[] it would happily work.

int[string] properties;

auto keyName = key.data; // `const(char)[]`
properties[keyName] = value; // works

const keyName = key.data; // compiler eats the other `const` and simplifies this to `const(char[])`
properties[keyName] = value; // doesn't work

Metadata

Metadata

Assignees

No one assigned

    Labels

    DruntimeSpecific to druntimeDruntime:AASpecific to Associative Arrays

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions