Skip to content

Commit d2cac67

Browse files
committed
add simple error message indicating dict syntax
1 parent e1b76f7 commit d2cac67

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

compiler/ml/error_message_utils.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ let print_extra_type_clash_help ~extract_concrete_typedecl ~env loc ppf
223223
\ - Use a tuple, if your array is of fixed length. Tuples can mix types \
224224
freely, and compiles to a JavaScript array. Example of a tuple: `let \
225225
myTuple = (10, \"hello\", 15.5, true)"
226+
| _, Some (_, {desc = Tconstr (p2, _, _)}) when Path.same Predef.path_dict p2
227+
->
228+
fprintf ppf
229+
"@,@,Dicts are written like: @{<info>dict{\"a\": 1, \"b\": 2}@}@,"
226230
| _, Some ({Types.desc = Tconstr (_p1, _, _)}, {desc = Tconstr (p2, _, _)})
227231
when Path.same Predef.path_unit p2 ->
228232
fprintf ppf
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
We've found a bug for you!
3+
/.../fixtures/dict_helper.res:3:11-23
4+
5+
1 │ external takesDict: dict<string> => unit = "takesDict"
6+
2 │
7+
3 │ takesDict({"test": "1"})
8+
4 │
9+
10+
This has type: {"test": string}
11+
But it's expected to have type: dict<string>
12+
13+
Dicts are written like: dict{"a": 1, "b": 2}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
external takesDict: dict<string> => unit = "takesDict"
2+
3+
takesDict({"test": "1"})

0 commit comments

Comments
 (0)