Skip to content

Commit f8e7e70

Browse files
committed
prefix instead of suffix
1 parent ca5df4e commit f8e7e70

File tree

5 files changed

+44
-44
lines changed

5 files changed

+44
-44
lines changed

jscomp/syntax/src/reactjs_jsx_v4.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ let vbMatch ~expr (name, default, _, alias, loc, _) =
858858
Vb.mk
859859
(Pat.var (Location.mkloc alias loc))
860860
(Exp.match_
861-
(Exp.ident {txt = Lident (alias ^ "__"); loc = Location.none})
861+
(Exp.ident {txt = Lident ("__" ^ alias); loc = Location.none})
862862
[
863863
Exp.case
864864
(Pat.construct
@@ -987,9 +987,9 @@ let mapBinding ~config ~emptyLoc ~pstr_loc ~fileName ~recFlag binding =
987987
let safePatternLabel pattern =
988988
match pattern with
989989
| {ppat_desc = Ppat_var {txt; loc}} ->
990-
{pattern with ppat_desc = Ppat_var {txt = txt ^ "__"; loc}}
990+
{pattern with ppat_desc = Ppat_var {txt = "__" ^ txt; loc}}
991991
| {ppat_desc = Ppat_alias (p, {txt; loc})} ->
992-
{pattern with ppat_desc = Ppat_alias (p, {txt = txt ^ "__"; loc})}
992+
{pattern with ppat_desc = Ppat_alias (p, {txt = "__" ^ txt; loc})}
993993
| _ -> pattern
994994
in
995995
let rec returnedExpression patternsWithLabel patternsWithNolabel
@@ -1013,7 +1013,7 @@ let mapBinding ~config ~emptyLoc ~pstr_loc ~fileName ~recFlag binding =
10131013
(*
10141014
If prop has the default value as Ident, it will get a build error
10151015
when the referenced Ident value and the prop have the same name.
1016-
So we add a "__" after label to resolve the build error.
1016+
So we add a "__" to label to resolve the build error.
10171017
*)
10181018
let patternWithSafeLabel =
10191019
match default with

jscomp/syntax/tests/ppx/react/expected/aliasProps.res.txt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
module C0 = {
44
type props<'priority, 'text> = {priority: 'priority, text?: 'text}
55

6-
let make = ({priority: _, text: ?text__, _}: props<_, _>) => {
7-
let text = switch text__ {
6+
let make = ({priority: _, text: ?__text, _}: props<_, _>) => {
7+
let text = switch __text {
88
| Some(text) => text
99
| None => "Test"
1010
}
@@ -21,8 +21,8 @@ module C0 = {
2121
module C1 = {
2222
type props<'priority, 'text> = {priority: 'priority, text?: 'text}
2323

24-
let make = ({priority: p, text: ?text__, _}: props<_, _>) => {
25-
let text = switch text__ {
24+
let make = ({priority: p, text: ?__text, _}: props<_, _>) => {
25+
let text = switch __text {
2626
| Some(text) => text
2727
| None => "Test"
2828
}
@@ -39,8 +39,8 @@ module C1 = {
3939
module C2 = {
4040
type props<'foo> = {foo?: 'foo}
4141

42-
let make = ({foo: ?bar__, _}: props<_>) => {
43-
let bar = switch bar__ {
42+
let make = ({foo: ?__bar, _}: props<_>) => {
43+
let bar = switch __bar {
4444
| Some(foo) => foo
4545
| None => ""
4646
}
@@ -57,12 +57,12 @@ module C2 = {
5757
module C3 = {
5858
type props<'foo, 'a, 'b> = {foo?: 'foo, a?: 'a, b: 'b}
5959

60-
let make = ({foo: ?bar__, a: ?a__, b, _}: props<_, _, _>) => {
61-
let bar = switch bar__ {
60+
let make = ({foo: ?__bar, a: ?__a, b, _}: props<_, _, _>) => {
61+
let bar = switch __bar {
6262
| Some(foo) => foo
6363
| None => ""
6464
}
65-
let a = switch a__ {
65+
let a = switch __a {
6666
| Some(a) => a
6767
| None => bar
6868
}
@@ -81,8 +81,8 @@ module C3 = {
8181
module C4 = {
8282
type props<'a, 'x> = {a: 'a, x?: 'x}
8383

84-
let make = ({a: b, x: ?x__, _}: props<_, _>) => {
85-
let x = switch x__ {
84+
let make = ({a: b, x: ?__x, _}: props<_, _>) => {
85+
let x = switch __x {
8686
| Some(x) => x
8787
| None => true
8888
}
@@ -99,8 +99,8 @@ module C4 = {
9999
module C5 = {
100100
type props<'a, 'z> = {a: 'a, z?: 'z}
101101

102-
let make = ({a: (x, y), z: ?z__, _}: props<_, _>) => {
103-
let z = switch z__ {
102+
let make = ({a: (x, y), z: ?__z, _}: props<_, _>) => {
103+
let z = switch __z {
104104
| Some(z) => z
105105
| None => 3
106106
}

jscomp/syntax/tests/ppx/react/expected/defaultValueProp.res.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module C0 = {
22
type props<'a, 'b> = {a?: 'a, b?: 'b}
3-
let make = ({a: ?a__, b: ?b__, _}: props<_, _>) => {
4-
let a = switch a__ {
3+
let make = ({a: ?__a, b: ?__b, _}: props<_, _>) => {
4+
let a = switch __a {
55
| Some(a) => a
66
| None => 2
77
}
8-
let b = switch b__ {
8+
let b = switch __b {
99
| Some(b) => b
1010
| None => a * 2
1111
}
@@ -21,8 +21,8 @@ module C0 = {
2121
module C1 = {
2222
type props<'a, 'b> = {a?: 'a, b: 'b}
2323

24-
let make = ({a: ?a__, b, _}: props<_, _>) => {
25-
let a = switch a__ {
24+
let make = ({a: ?__a, b, _}: props<_, _>) => {
25+
let a = switch __a {
2626
| Some(a) => a
2727
| None => 2
2828
}
@@ -40,8 +40,8 @@ module C2 = {
4040
let a = "foo"
4141
type props<'a> = {a?: 'a}
4242

43-
let make = ({a: ?a__, _}: props<_>) => {
44-
let a = switch a__ {
43+
let make = ({a: ?__a, _}: props<_>) => {
44+
let a = switch __a {
4545
| Some(a) => a
4646
| None => a
4747
}
@@ -58,8 +58,8 @@ module C2 = {
5858
module C3 = {
5959
type props<'disabled> = {disabled?: 'disabled}
6060

61-
let make = ({disabled: ?everythingDisabled__, _}: props<bool>) => {
62-
let everythingDisabled = switch everythingDisabled__ {
61+
let make = ({disabled: ?__everythingDisabled, _}: props<bool>) => {
62+
let everythingDisabled = switch __everythingDisabled {
6363
| Some(disabled) => disabled
6464
| None => false
6565
}

jscomp/syntax/tests/ppx/react/expected/uncurriedProps.res.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
@@jsxConfig({version: 4})
22
type props<'a> = {a?: 'a}
33

4-
let make = ({a: ?a__, _}: props<(. unit) => unit>) => {
5-
let a = switch a__ {
4+
let make = ({a: ?__a, _}: props<(. unit) => unit>) => {
5+
let a = switch __a {
66
| Some(a) => a
77
| None => (. ()) => ()
88
}
@@ -28,8 +28,8 @@ func(~callback=(. str, a, b) => {
2828
module Foo = {
2929
type props<'callback> = {callback?: 'callback}
3030

31-
let make = ({callback: ?callback__, _}: props<(. string, bool, bool) => unit>) => {
32-
let callback = switch callback__ {
31+
let make = ({callback: ?__callback, _}: props<(. string, bool, bool) => unit>) => {
32+
let callback = switch __callback {
3333
| Some(callback) => callback
3434
| None => (. _, _, _) => ()
3535
}

jscomp/test/alias_default_value_test.js

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)