Skip to content

Commit e40e8c2

Browse files
Brandon Wufacebook-github-bot
Brandon Wu
authored andcommitted
Changed error message for invalid type parameters to include Subtract
Summary: + Problem: The error message for failing to give arithmetic type operators types that are a subtype of int does not include `Subtract`. + Background: In the previous diff, we implemented the `Subtract` type operator. When it fails (and is given arguments that are not a subtype of int), a particular error message displays, which is hard-coded to include `Add`, `Multiply`, and `Divide`, but not `Subtract`. + Solution: This diff just makes `Subtract` included in that message. Reviewed By: pradeep90 Differential Revision: D30049950 fbshipit-source-id: d4b17b32d83428a02f36094cff73e87365d37b12
1 parent 6a3d99c commit e40e8c2

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

source/analysis/analysisError.ml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1255,8 +1255,9 @@ let rec messages ~concise ~signature location kind =
12551255
[
12561256
Format.asprintf
12571257
"Type parameter `%a` violates constraints on \
1258-
`pyre_extensions.Add`/`pyre_extensions.Multiply`/`pyre_extensions.Divide`. Add & \
1259-
Multiply & Divide only accept type variables with a bound that's a subtype of int."
1258+
`pyre_extensions.Add`/`pyre_extensions.Multiply`/`pyre_extensions.Subtract`/`pyre_extensions.Divide`. \
1259+
Add & Multiply & Subtract & Divide only accept type variables with a bound that's a \
1260+
subtype of int."
12601261
pp_type
12611262
actual;
12621263
]

source/analysis/test/integration/annotationTest.ml

+12-8
Original file line numberDiff line numberDiff line change
@@ -1853,14 +1853,17 @@ let test_check_typevar_arithmetic context =
18531853
|}
18541854
[
18551855
"Invalid type parameters [24]: Type parameter `Variable[A]` violates constraints on \
1856-
`pyre_extensions.Add`/`pyre_extensions.Multiply`/`pyre_extensions.Divide`. Add & Multiply & \
1857-
Divide only accept type variables with a bound that's a subtype of int.";
1856+
`pyre_extensions.Add`/`pyre_extensions.Multiply`/`pyre_extensions.Subtract`/`pyre_extensions.Divide`. \
1857+
Add & Multiply & Subtract & Divide only accept type variables with a bound that's a subtype \
1858+
of int.";
18581859
"Invalid type parameters [24]: Type parameter `Variable[A]` violates constraints on \
1859-
`pyre_extensions.Add`/`pyre_extensions.Multiply`/`pyre_extensions.Divide`. Add & Multiply & \
1860-
Divide only accept type variables with a bound that's a subtype of int.";
1860+
`pyre_extensions.Add`/`pyre_extensions.Multiply`/`pyre_extensions.Subtract`/`pyre_extensions.Divide`. \
1861+
Add & Multiply & Subtract & Divide only accept type variables with a bound that's a subtype \
1862+
of int.";
18611863
"Invalid type parameters [24]: Type parameter `Variable[A]` violates constraints on \
1862-
`pyre_extensions.Add`/`pyre_extensions.Multiply`/`pyre_extensions.Divide`. Add & Multiply & \
1863-
Divide only accept type variables with a bound that's a subtype of int.";
1864+
`pyre_extensions.Add`/`pyre_extensions.Multiply`/`pyre_extensions.Subtract`/`pyre_extensions.Divide`. \
1865+
Add & Multiply & Subtract & Divide only accept type variables with a bound that's a subtype \
1866+
of int.";
18641867
];
18651868
assert_type_errors
18661869
{|
@@ -3424,8 +3427,9 @@ let test_check_subtract context =
34243427
|}
34253428
[
34263429
"Invalid type parameters [24]: Type parameter `Variable[A]` violates constraints on \
3427-
`pyre_extensions.Add`/`pyre_extensions.Multiply`/`pyre_extensions.Divide`. Add & Multiply & \
3428-
Divide only accept type variables with a bound that's a subtype of int.";
3430+
`pyre_extensions.Add`/`pyre_extensions.Multiply`/`pyre_extensions.Subtract`/`pyre_extensions.Divide`. \
3431+
Add & Multiply & Subtract & Divide only accept type variables with a bound that's a subtype \
3432+
of int.";
34293433
];
34303434
assert_default_type_errors
34313435
{|

0 commit comments

Comments
 (0)