Skip to content

remove T{} syntax in favor of type coercion #5038

@andrewrk

Description

@andrewrk

The following are semantically equivalent:

const a = T{};
const a: T = .{};
const a = @as(T, .{});

I propose to remove the first possibility, and rely on the other two.

The problem with this proposal as I can see it is inferred-size array literals:

const a = [_]u8{1, 2, 3};

There's no other way to write this. And if that works, then why wouldn't this work?

const a = [3]u8{1, 2, 3};

But now we're back to the proposal:

const a = [3]u8{1, 2, 3};
const a: [3]u8 = .{1, 2, 3};
const a = @as([3]u8, .{1, 2, 3});

Metadata

Metadata

Assignees

No one assigned

    Labels

    breakingImplementing this issue could cause existing code to no longer compile or have different behavior.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions