tc39 / ecmarkup

An HTML superset/Markdown subset source format for ECMAScript and related specifications
https://tc39.es/ecmarkup/
MIT License
221 stars 63 forks source link

special handling for Completion/NormalCompletion in the typechecker #613

Closed bakkot closed 2 months ago

bakkot commented 2 months ago

Based on https://github.com/tc39/ecmarkup/pull/612.

We don't (and are not going to) have generic types, so just hardcode these specific generic types. Also observe that a normal completion of never is equivalent to never, which allows us to get errors when passing NormalCompletion(x) to NormalCompletion(not-x). The latter doesn't really come up for arguments but it does for returned values, which I want to handle soon.

bakkot commented 2 months ago

We should add an assertNoTypeError test for a normal completion containing an ECMAScript language value and NormalCompletion(*true*) or something (the normal completion parameter type being a subtype of the declared type).

Done. Though our type system represents false as a distinct type from Boolean, so strictly speaking we already had that.

michaelficarra commented 2 months ago

I guess we could simplify that other test to a normal completion containing *false* if we wanted.