Skip to content

Support casts in comptime constants #5160

@michaeljklein

Description

@michaeljklein

Problem

Attempting to use a cast in an a comptime global:

global SOME_CONSTANT: u64 = 7;
global OTHER_CONSTANT: u64 = 1 << SOME_CONSTANT as u8;

Fails with: Expression invalid in an array-length context

Happy Case

OTHER_CONSTANT is equivalent to 1 << 7u8

Project Impact

Nice-to-have

Impact Context

No response

Workaround

None

Workaround Description

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

Yes

Support Needs

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions