winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
5.06k stars 198 forks source link

`std.reflect.Type` field `kind` should be enum #7184

Open Chriscbr opened 1 month ago

Chriscbr commented 1 month ago

Use Case

To reduce bugs with writing code that is reflection heavy and dispatches based on what types have been reflected, it would be preferable to restrict the "kind" field to a fixed set of choices.

Example, instead of:

let t = @type(Array<str>);
assert(t.kind == "array");

it can be:

assert(t.kind == std.reflect.TypeId.ARRAY);
// or
assert(t.kind == .ARRAY);

Proposed Solution

No response

Implementation Notes

No response

Component

Compiler, SDK

Community Notes