-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
Typing: soundnessNo false negatives (type checker claims that there is no error in the incorrect program)No false negatives (type checker claims that there is no error in the incorrect program)Typing: unions/intersectionsbug
Description
Flow v0.91.0 accepts the following (try):
function fn<T, U>(x: $ReadOnly<T & U>): T {
return x;
}
const exact: {| a: any |} = fn<{| a: any |}, { b: any }>({ a: 1, b: 1 });This potential for unsoundness with intersections of exact types was noted in this comment in the discussion about adding exact types to TypeScript.
The comment notes "it's really not OK to error on instantiation" -- is this a principle Flow adheres to as well? If so, it seems there is indeed no way to make this sound. But if not, this should be an error -- something like "Cannot call fn with object literal bound to x because object literal [1] is incompatible with empty [2]."
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Typing: soundnessNo false negatives (type checker claims that there is no error in the incorrect program)No false negatives (type checker claims that there is no error in the incorrect program)Typing: unions/intersectionsbug