-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
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)bug
Description
The following code should obviously have a type error, but does not:
// @flow
const key: string = "magic";
const o: {[string]: number} = {[key]: "I am not a number"}; // no type error!!!
o.magic.toFixed(); // runtime error// @flow
const annotated: string = "hi";
({[annotated]: "I am not a number"}: {[string]: number}); // no error!!!
({[annotated]: "I am not a number"}: {|[string]: number|}); // even when exact
({[annotated]: "I am not a number"}: {+[string]: number}); // or covariant
({[annotated]: "I am not a number"}: {|+[string]: number|}); // or both
const inferred = "hi";
({[inferred]: "I am not a number"}: {[string]: number}); // properly failsEdit: It appears that the key is not checked, either:
// @flow
type Fruit = "APPLE" | "ORANGE";
const properlyFails1: {[Fruit]: number} = {BRICK: 123};
const properlyFails2: {[Fruit]: number} = {["BRICK"]: 234};
const wat3: {[Fruit]: number} = {[("BRICK": string)]: 345}; // no error!!!
const wat4: {[Fruit]: number} = {[("BRICK": string)]: "wat"}; // no error!!!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)bug