In the following code:
function identity<A>(x: A): A {
return x + x;
}
// $ flow
// No errors!
I expected Flow to give me a type error in x + x, because the abstract type A is incompatible with the types expected by the + operator. However, Flow incorrectly says that there are no type errors in this code.
Other operators work as expected:
function identity<A>(x: A): A {
return x - x;
}
// $ flow
// id.js:4
// 4: return x - x;
// ^ A. This type is incompatible with
// 4: return x - x;
// ^^^^^ number
//
// id.js:4
// 4: return x - x;
// ^^^^^ number. This type is incompatible with
// 3: function identity<A>(x: A): A {
// ^ some incompatible instantiation of `A`
//
// id.js:4
// 4: return x - x;
// ^ A. This type is incompatible with
// 4: return x - x;
// ^^^^^ number
//
//
// Found 3 errors
@mroch fixed this in 0.33. Error output is now:
4: return x + x;
^ A. Cannot be added to
4: return x + x;
^ A
Most helpful comment
@mroch fixed this in 0.33. Error output is now: