Skip to content

Fix uppercase exotic field format #6897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jscomp/core/js_dump_property.ml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ let property_access f s =
let property_key (s : J.property_name) : string =
match s with
| Lit s ->
let s = Ext_ident.unwrap_uppercase_exotic s in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering whether s should have its own type other than string, so that one gets a reminder to do the unwrapping.
Here and in the other cases of ids.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, can be investigated separately.

if obj_property_no_need_quot s then s
else Js_dump_string.escape_to_string s
| Symbol_name -> {|[Symbol.for("name")]|}
4 changes: 3 additions & 1 deletion jscomp/syntax/tests/oprint/expected/oprint.resi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ type t22 = [#"Variant ⛰"]
type \"let" = int
type \"type" = [#"Point🗿"(\"let", float)]
type t23 = [#1 | #"10space" | #123]
type exoticUser = {\"let": string, \"type": float}
type exoticUser = {\"let": string, \"type": float, \"Upper": int}
type arity1a = unit => int
type arity1b = int => int
type arity2 = (int, int) => int
Expand All @@ -184,6 +184,7 @@ type obj6 = {"a": int}
type obj7 = {"a": int}
type obj8<'a> = 'a
constraint 'a = {.."a": int}
type obj9 = {"A": int}
type objUser = {"age": int, "name": string}
type objUserWithLongFields = {
"age": int,
Expand All @@ -192,6 +193,7 @@ type objUserWithLongFields = {
"name": string,
"x": int,
}
type objUserWithUppsercaseKeys = {"AGE": int, "NAME": string}
type objectCoordinate = {"x": float, "y": float}
type threeDimensionalCoordinate = {"x": float, "y": float, "z": float}
type differentSpreadedCoordinate = {
Expand Down
5 changes: 4 additions & 1 deletion jscomp/syntax/tests/oprint/oprint.res
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ type t23 = [

type exoticUser = {
\"let": string,
\"type": float
\"type": float,
\"Upper": int
}

type arity1a = (. ()) => int
Expand All @@ -230,9 +231,11 @@ type obj5<'a> = {..} as 'a
type obj6 = {"a": int}
type obj7 = {. "a": int}
type obj8<'a> = {.. "a": int} as 'a
type obj9 = {"A": int}

type objUser = {"name": string, "age": int}
type objUserWithLongFields = {"name": string, "x": int, "age": int, "looooooongFiiiiiiiieeeeeeeldName": string, "anoooooooooooooooootherLongFiiiiiieeeeeeeldName": int}
type objUserWithUppsercaseKeys = {"NAME": string, "AGE": int}

type objectCoordinate = {"x": float, "y": float}
type threeDimensionalCoordinate = {...objectCoordinate, "z": float}
Expand Down
10 changes: 10 additions & 0 deletions jscomp/syntax/tests/printer/expr/exoticIdent.res
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,13 @@ assert(\"let")
let x = 1

let x = <div \"aria-foo"=\"type"> \"module" \"let" </div>;

type dict = {
\"key": int,
\"KEY": int,
}

let dict = {
\"key": 42,
\"KEY": 42,
}
10 changes: 10 additions & 0 deletions jscomp/syntax/tests/printer/expr/expected/exoticIdent.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,13 @@ let x =
\"module"
\"let"
</div>

type dict = {
key: int,
\"KEY": int,
}

let dict = {
key: 42,
\"KEY": 42,
}
6 changes: 6 additions & 0 deletions jscomp/test/exotic_labels_test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions jscomp/test/exotic_labels_test.res
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,13 @@ type \"Type4" = {
field: string,
}
let fn1 = v => v.field

type dict = {
\"key": int,
\"KEY": int,
}

let dict = {
\"key": 1,
\"KEY": 1,
}