Skip to content

Conversation

HerrCai0907
Copy link
Member

@HerrCai0907 HerrCai0907 commented Sep 25, 2025

No description provided.

@CountBleck
Copy link
Member

Concept ACK but I'll have to review later

@HerrCai0907
Copy link
Member Author

ping @CountBleck

Copy link
Member

@CountBleck CountBleck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems decent

Comment on lines +1543 to +1545
for (let _keys = Map_keys(members), _values = Map_values(members), i = 1, k = _keys.length; i <= k; ++i) {
let enumValueName = unchecked(_keys[k - i]);
let member = unchecked(_values[k - i]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (let _keys = Map_keys(members), _values = Map_values(members), i = 1, k = _keys.length; i <= k; ++i) {
let enumValueName = unchecked(_keys[k - i]);
let member = unchecked(_values[k - i]);
for (let _keys = Map_keys(members), _values = Map_values(members), i = _keys.length - 1; i >= 0; --i) {
let enumValueName = unchecked(_keys[i]);
let member = unchecked(_values[i]);

Doesn't this work?

return true;
}

private ensureEnumToString(enumElement: Enum, reportNode: Node): string | null {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a couple blank lines in here? It's a little hard to read

let resolver = this.resolver;
let targetElement = resolver.lookupExpression(targetExpression, this.currentFlow, Type.auto, ReportMode.Swallow);
if (targetElement && targetElement.kind == ElementKind.Enum) {
const elementExpr = this.compileExpression(expression.elementExpression, Type.i32, Constraints.ConvImplicit);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we're allowing Enum[Enum.X] but not Enum["X"] (only Enum.X, the property access expression, is allowed). This is likely a good thing to have, unless users really want to get enum members with computed string values (which should probably be discouraged regardless).

(It also seems like we don't have a good error for someObject["property"] and we use TS2329 instead, so a good error for Enum["X"] isn't necessary for now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants