Skip to content

Commit fc4eec8

Browse files
cristianocmununki
authored andcommitted
Adapt @as ppx to new string literals.
String literals are now represented as `{j*|xxx|j*}`. Chang the `@as` ppx accordingly.
1 parent 58b281a commit fc4eec8

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

jscomp/frontend/ast_attributes.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,15 +292,16 @@ let iter_process_bs_string_or_int_as (attrs : Parsetree.attributes) =
292292
pexp_desc =
293293
Pexp_constant
294294
(Pconst_string
295-
(s, ((None | Some "json") as dec)));
295+
(s, ((None | Some "json"| Some "*j") as dec)));
296296
pexp_loc;
297297
_;
298298
},
299299
_ );
300300
_;
301301
};
302-
] ->
303-
if dec = None then st := Some (Str s)
302+
]
303+
->
304+
if dec = None || dec = Some "*j" then st := Some (Str s)
304305
else (
305306
(match
306307
Classify_function.classify
@@ -313,7 +314,7 @@ let iter_process_bs_string_or_int_as (attrs : Parsetree.attributes) =
313314
Location.raise_errorf ~loc:pexp_loc
314315
"an object literal expected");
315316
st := Some (Js_literal_str s))
316-
| _ -> Bs_syntaxerr.err loc Expect_int_or_string_or_json_literal
317+
| _ -> Bs_syntaxerr.err loc (Expect_int_or_string_or_json_literal)
317318
)
318319
| Some v -> st := Some (Int v))
319320
else Bs_syntaxerr.err loc Duplicated_bs_as

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254524,15 +254524,16 @@ let iter_process_bs_string_or_int_as (attrs : Parsetree.attributes) =
254524254524
pexp_desc =
254525254525
Pexp_constant
254526254526
(Pconst_string
254527-
(s, ((None | Some "json") as dec)));
254527+
(s, ((None | Some "json"| Some "*j") as dec)));
254528254528
pexp_loc;
254529254529
_;
254530254530
},
254531254531
_ );
254532254532
_;
254533254533
};
254534-
] ->
254535-
if dec = None then st := Some (Str s)
254534+
]
254535+
->
254536+
if dec = None || dec = Some "*j" then st := Some (Str s)
254536254537
else (
254537254538
(match
254538254539
Classify_function.classify
@@ -254545,7 +254546,7 @@ let iter_process_bs_string_or_int_as (attrs : Parsetree.attributes) =
254545254546
Location.raise_errorf ~loc:pexp_loc
254546254547
"an object literal expected");
254547254548
st := Some (Js_literal_str s))
254548-
| _ -> Bs_syntaxerr.err loc Expect_int_or_string_or_json_literal
254549+
| _ -> Bs_syntaxerr.err loc (Expect_int_or_string_or_json_literal)
254549254550
)
254550254551
| Some v -> st := Some (Int v))
254551254552
else Bs_syntaxerr.err loc Duplicated_bs_as

lib/4.06.1/whole_compiler.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258595,15 +258595,16 @@ let iter_process_bs_string_or_int_as (attrs : Parsetree.attributes) =
258595258595
pexp_desc =
258596258596
Pexp_constant
258597258597
(Pconst_string
258598-
(s, ((None | Some "json") as dec)));
258598+
(s, ((None | Some "json"| Some "*j") as dec)));
258599258599
pexp_loc;
258600258600
_;
258601258601
},
258602258602
_ );
258603258603
_;
258604258604
};
258605-
] ->
258606-
if dec = None then st := Some (Str s)
258605+
]
258606+
->
258607+
if dec = None || dec = Some "*j" then st := Some (Str s)
258607258608
else (
258608258609
(match
258609258610
Classify_function.classify
@@ -258616,7 +258617,7 @@ let iter_process_bs_string_or_int_as (attrs : Parsetree.attributes) =
258616258617
Location.raise_errorf ~loc:pexp_loc
258617258618
"an object literal expected");
258618258619
st := Some (Js_literal_str s))
258619-
| _ -> Bs_syntaxerr.err loc Expect_int_or_string_or_json_literal
258620+
| _ -> Bs_syntaxerr.err loc (Expect_int_or_string_or_json_literal)
258620258621
)
258621258622
| Some v -> st := Some (Int v))
258622258623
else Bs_syntaxerr.err loc Duplicated_bs_as

0 commit comments

Comments
 (0)