Skip to content

Commit e5ebb62

Browse files
committed
Fix uppercase field names on record
Fixed rescript-lang#6882
1 parent 7d6b8d9 commit e5ebb62

File tree

7 files changed

+44
-2
lines changed

7 files changed

+44
-2
lines changed

jscomp/core/js_dump_property.ml

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ let property_access f s =
8484
let property_key (s : J.property_name) : string =
8585
match s with
8686
| Lit s ->
87+
let s = Ext_ident.unwrap_uppercase_exotic s in
8788
if obj_property_no_need_quot s then s
8889
else Js_dump_string.escape_to_string s
8990
| Symbol_name -> {|[Symbol.for("name")]|}

jscomp/syntax/tests/oprint/expected/oprint.resi.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ type t22 = [#"Variant ⛰"]
170170
type \"let" = int
171171
type \"type" = [#"Point🗿"(\"let", float)]
172172
type t23 = [#1 | #"10space" | #123]
173-
type exoticUser = {\"let": string, \"type": float}
173+
type exoticUser = {\"let": string, \"type": float, \"Upper": int}
174174
type arity1a = unit => int
175175
type arity1b = int => int
176176
type arity2 = (int, int) => int
@@ -184,6 +184,7 @@ type obj6 = {"a": int}
184184
type obj7 = {"a": int}
185185
type obj8<'a> = 'a
186186
constraint 'a = {.."a": int}
187+
type obj9 = {"A": int}
187188
type objUser = {"age": int, "name": string}
188189
type objUserWithLongFields = {
189190
"age": int,
@@ -192,6 +193,7 @@ type objUserWithLongFields = {
192193
"name": string,
193194
"x": int,
194195
}
196+
type objUserWithUppsercaseKeys = {"AGE": int, "NAME": string}
195197
type objectCoordinate = {"x": float, "y": float}
196198
type threeDimensionalCoordinate = {"x": float, "y": float, "z": float}
197199
type differentSpreadedCoordinate = {

jscomp/syntax/tests/oprint/oprint.res

+4-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ type t23 = [
215215

216216
type exoticUser = {
217217
\"let": string,
218-
\"type": float
218+
\"type": float,
219+
\"Upper": int
219220
}
220221

221222
type arity1a = (. ()) => int
@@ -230,9 +231,11 @@ type obj5<'a> = {..} as 'a
230231
type obj6 = {"a": int}
231232
type obj7 = {. "a": int}
232233
type obj8<'a> = {.. "a": int} as 'a
234+
type obj9 = {"A": int}
233235

234236
type objUser = {"name": string, "age": int}
235237
type objUserWithLongFields = {"name": string, "x": int, "age": int, "looooooongFiiiiiiiieeeeeeeldName": string, "anoooooooooooooooootherLongFiiiiiieeeeeeeldName": int}
238+
type objUserWithUppsercaseKeys = {"NAME": string, "AGE": int}
236239

237240
type objectCoordinate = {"x": float, "y": float}
238241
type threeDimensionalCoordinate = {...objectCoordinate, "z": float}

jscomp/syntax/tests/printer/expr/exoticIdent.res

+10
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,13 @@ assert(\"let")
5252
let x = 1
5353

5454
let x = <div \"aria-foo"=\"type"> \"module" \"let" </div>;
55+
56+
type dict = {
57+
\"key": int,
58+
\"KEY": int,
59+
}
60+
61+
let dict = {
62+
\"key": 42,
63+
\"KEY": 42,
64+
}

jscomp/syntax/tests/printer/expr/expected/exoticIdent.res.txt

+10
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,13 @@ let x =
6464
\"module"
6565
\"let"
6666
</div>
67+
68+
type dict = {
69+
key: int,
70+
\"KEY": int,
71+
}
72+
73+
let dict = {
74+
key: 42,
75+
\"KEY": 42,
76+
}

jscomp/test/exotic_labels_test.js

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/exotic_labels_test.res

+10
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,13 @@ type \"Type4" = {
88
field: string,
99
}
1010
let fn1 = v => v.field
11+
12+
type dict = {
13+
\"key": int,
14+
\"KEY": int,
15+
}
16+
17+
let dict = {
18+
\"key": 1,
19+
\"KEY": 1,
20+
}

0 commit comments

Comments
 (0)