Skip to content

Commit 636f978

Browse files
committed
use String.sub intead of unwrap_uppercase_exotic
1 parent 10146ef commit 636f978

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

jscomp/syntax/src/res_printer.ml

+4-6
Original file line numberDiff line numberDiff line change
@@ -436,12 +436,10 @@ let print_poly_var_ident txt =
436436
else
437437
match classify_ident_content ~allow_uident:true txt with
438438
| UppercaseExoticIdent ->
439-
Doc.concat
440-
[
441-
Doc.text "\"";
442-
Doc.text (Ext_ident.unwrap_uppercase_exotic txt);
443-
Doc.text "\"";
444-
]
439+
let len = String.length txt in
440+
(* UppercaseExoticIdent follows the \"..." format,
441+
so removing the leading backslash is enough to transform it into polyvar style *)
442+
Doc.text ((String.sub [@doesNotRaise]) txt 1 (len - 1))
445443
| ExoticIdent -> Doc.concat [Doc.text "\""; Doc.text txt; Doc.text "\""]
446444
| NormalIdent -> (
447445
match txt with

0 commit comments

Comments
 (0)