Skip to content

Commit 610cec1

Browse files
committed
Recommend stdlib functions over Belt for converting between float/int/string
1 parent 6e7f3d3 commit 610cec1

27 files changed

+32
-32
lines changed

compiler/ml/typecore.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -676,12 +676,12 @@ let rec bottom_aliases = function
676676

677677
let simple_conversions =
678678
[
679-
(("float", "int"), "Belt.Float.toInt");
680-
(("float", "string"), "Belt.Float.toString");
681-
(("int", "float"), "Belt.Int.toFloat");
682-
(("int", "string"), "Belt.Int.toString");
683-
(("string", "float"), "Belt.Float.fromString");
684-
(("string", "int"), "Belt.Int.fromString");
679+
(("float", "int"), "Float.toInt");
680+
(("float", "string"), "Float.toString");
681+
(("int", "float"), "Int.toFloat");
682+
(("int", "string"), "Int.toString");
683+
(("string", "float"), "Float.fromString");
684+
(("string", "int"), "Int.fromString");
685685
]
686686

687687
let print_simple_conversion ppf (actual, expected) =

tests/build_tests/super_errors/expected/array_item_type_mismatch.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
- Convert all values in the array to the same type.
1515
- Use a tuple, if your array is of fixed length. Tuples can mix types freely, and compiles to a JavaScript array. Example of a tuple: `let myTuple = (10, "hello", 15.5, true)
1616

17-
You can convert string to int with Belt.Int.fromString.
17+
You can convert string to int with Int.fromString.

tests/build_tests/super_errors/expected/collections.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
This has type: string
1010
But it's expected to have type: int
1111

12-
You can convert string to int with Belt.Int.fromString.
12+
You can convert string to int with Int.fromString.

tests/build_tests/super_errors/expected/dict_inference.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
This has type: string
1111
But this function argument is expecting: int
1212

13-
You can convert string to int with Belt.Int.fromString.
13+
You can convert string to int with Int.fromString.

tests/build_tests/super_errors/expected/dict_pattern_inference_constrained.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
The incompatible parts:
1515
int vs string
1616

17-
You can convert int to string with Belt.Int.toString.
17+
You can convert int to string with Int.toString.

tests/build_tests/super_errors/expected/function_argument_mismatch.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
This has type: int
1111
But this function argument is expecting: string
1212

13-
You can convert int to string with Belt.Int.toString.
13+
You can convert int to string with Int.toString.

tests/build_tests/super_errors/expected/highlighting1.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
This has type: string
1111
But it's expected to have type: int
1212

13-
You can convert string to int with Belt.Int.fromString.
13+
You can convert string to int with Int.fromString.

tests/build_tests/super_errors/expected/highlighting2.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
This has type: string
1111
But it's expected to have type: int
1212

13-
You can convert string to int with Belt.Int.fromString.
13+
You can convert string to int with Int.fromString.

tests/build_tests/super_errors/expected/highlighting3.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
This has type: string
1111
But it's expected to have type: int
1212

13-
You can convert string to int with Belt.Int.fromString.
13+
You can convert string to int with Int.fromString.

tests/build_tests/super_errors/expected/highlighting5.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
This has type: string
1111
But it's expected to have type: int
1212

13-
You can convert string to int with Belt.Int.fromString.
13+
You can convert string to int with Int.fromString.

tests/build_tests/super_errors/expected/if_branch_mismatch.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313

1414
if expressions must return the same type in all branches (if, else if, else).
1515

16-
You can convert int to string with Belt.Int.toString.
16+
You can convert int to string with Int.toString.

tests/build_tests/super_errors/expected/inline_types_record_type_params.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
This has type: int
1212
But it's expected to have type: string
1313

14-
You can convert int to string with Belt.Int.toString.
14+
You can convert int to string with Int.toString.

tests/build_tests/super_errors/expected/math_operator_constant.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
This has type: float
1111
But it's expected to have type: int
1212

13-
You can convert float to int with Belt.Float.toInt.
13+
You can convert float to int with Float.toInt.
1414
If this is a literal, try a number without a trailing dot (e.g. 20).

tests/build_tests/super_errors/expected/math_operator_float.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
- Ensure all values in this calculation has the type float. You can convert between floats and ints via Belt.Float.toInt and Belt.Int.fromFloat.
1717
- Change the operator to +, which works on int
1818

19-
You can convert int to float with Belt.Int.toFloat.
19+
You can convert int to float with Int.toFloat.
2020
If this is a literal, try a number with a trailing dot (e.g. 20.).

tests/build_tests/super_errors/expected/primitives1.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
This has type: int
1010
But it's expected to have type: float
1111

12-
You can convert int to float with Belt.Int.toFloat.
12+
You can convert int to float with Int.toFloat.
1313
If this is a literal, try a number with a trailing dot (e.g. 20.).

tests/build_tests/super_errors/expected/primitives11.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
Further expanded:
1717
int vs string
1818

19-
You can convert int to string with Belt.Int.toString.
19+
You can convert int to string with Int.toString.

tests/build_tests/super_errors/expected/primitives2.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
This has type: int
1010
But string concatenation is expecting: string
1111

12-
You can convert int to string with Belt.Int.toString.
12+
You can convert int to string with Int.toString.

tests/build_tests/super_errors/expected/primitives6.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
This has type: int
1111
But it's expected to have type: float
1212

13-
You can convert int to float with Belt.Int.toFloat.
13+
You can convert int to float with Int.toFloat.
1414
If this is a literal, try a number with a trailing dot (e.g. 20.).

tests/build_tests/super_errors/expected/primitives7.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
- Ensure all values in this calculation has the type float. You can convert between floats and ints via Belt.Float.toInt and Belt.Int.fromFloat.
1717
- Change the operator to +, which works on int
1818

19-
You can convert int to float with Belt.Int.toFloat.
19+
You can convert int to float with Int.toFloat.
2020
If this is a literal, try a number with a trailing dot (e.g. 20.).

tests/build_tests/super_errors/expected/primitives9.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
This has type: string
99
But it's expected to have type: int
1010

11-
You can convert string to int with Belt.Int.fromString.
11+
You can convert string to int with Int.fromString.

tests/build_tests/super_errors/expected/record_type_spreads_deep_sub.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
This has type: string
1212
But it's expected to have type: int
1313

14-
You can convert string to int with Belt.Int.fromString.
14+
You can convert string to int with Int.fromString.

tests/build_tests/super_errors/expected/set_record_field_type_match.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
You're assigning something to this field that has type: int
1111
But this record field is of type: string
1212

13-
You can convert int to string with Belt.Int.toString.
13+
You can convert int to string with Int.toString.

tests/build_tests/super_errors/expected/stdlib_removed_in_error.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
The incompatible parts:
1414
string vs int
1515

16-
You can convert string to int with Belt.Int.fromString.
16+
You can convert string to int with Int.fromString.

tests/build_tests/super_errors/expected/syntaxErrors4.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
This has type: string
1616
But it's expected to have type: int
1717

18-
You can convert string to int with Belt.Int.fromString.
18+
You can convert string to int with Int.fromString.

tests/build_tests/super_errors/expected/type1.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
This has type: int
99
But it's expected to have type: float
1010

11-
You can convert int to float with Belt.Int.toFloat.
11+
You can convert int to float with Int.toFloat.
1212
If this is a literal, try a number with a trailing dot (e.g. 20.).

tests/build_tests/super_errors/expected/type2.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
This has type: string
1212
But this function argument is expecting: int
1313

14-
You can convert string to int with Belt.Int.fromString.
14+
You can convert string to int with Int.fromString.

tests/build_tests/super_errors/expected/unicode_location.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
This has type: int
1111
But string concatenation is expecting: string
1212

13-
You can convert int to string with Belt.Int.toString.
13+
You can convert int to string with Int.toString.

0 commit comments

Comments
 (0)