Skip to content

treat enums as never members of unknown types#714

Open
bakkot wants to merge 1 commit into
mainfrom
enum-error
Open

treat enums as never members of unknown types#714
bakkot wants to merge 1 commit into
mainfrom
enum-error

Conversation

@bakkot

@bakkot bakkot commented Jul 23, 2026

Copy link
Copy Markdown
Member

The type lattice is deliberately conservative; when it encounters a type name it doesn't recognize, like PrivateElement, it assumes that could hold anything and as such it is never an error to assign any value to something of that type.

This heuristic is generally necessary; e.g. a property key is a String or a Symbol, and "property key" is an unknown type, so it is good that ecmarkup does not regard it as an error to assign a String to an unknown type.

However, we don't and (I weakly believe) shouldn't define any types that hold enums. This means we can assume a type name we don't recognize cannot hold an enum, and so assigning an enum specifically to such a type is an error.

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