Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 9278966

Browse files
authored
466: Fix missing js attribute for string in braces (#494)
1 parent 73b4e22 commit 9278966

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

src/res_core.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2772,7 +2772,7 @@ and parseBracedOrRecordExpr p =
27722772
Parser.expect Rbrace p;
27732773
expr
27742774
| _ ->
2775-
let constant = Ast_helper.Exp.constant ~loc:field.loc (Parsetree.Pconst_string(s, None)) in
2775+
let constant = Ast_helper.Exp.constant ~loc:field.loc (Parsetree.Pconst_string(s, Some("js"))) in
27762776
let a = parsePrimaryExpr ~operand:constant p in
27772777
let e = parseBinaryExpr ~a p 1 in
27782778
let e = parseTernaryExpr e p in

tests/parsing/errors/expressions/expected/letBinding.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,5 @@ let foo = true
8484
let foo = 2
8585
let foo = f ()
8686
let foo = ((2)[@ns.braces ])
87-
let foo = (("foo")[@ns.braces ])
87+
let foo = (({js|foo|js})[@ns.braces ])
8888
let foo as x = ()

tests/parsing/grammar/expressions/expected/bracedOrRecord.res.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ let e = (((fun x -> x + 1) |> sideEffect; logToAnalytics Shady.ml)
2424
let f = ((fun event -> (event.target).value)[@ns.braces ])
2525
let f = ((fun event -> ((event.target).value : string))[@ns.braces ])
2626
let x = ((let a = 1 in let b = 2 in a + b)[@ns.braces ])
27-
;;(([(("\n" |. React.string)[@ns.braces ])])[@JSX ])
27+
;;(([(({js|
28+
|js} |. React.string)[@ns.braces ])])[@JSX ])

tests/parsing/grammar/expressions/expected/bsObject.res.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ let x = [%obj { age = 30 }]
22
let y = [%obj { age = 30 }]
33
let y = [%obj { age = 30; name = {js|steve|js} }]
44
let y = [%obj { age = 30; name = {js|steve|js} }]
5-
let x = (("age")[@ns.braces ])
6-
let x = (("age".(0))[@ns.braces ])
7-
let x = (("age" |. Js.log)[@ns.braces ])
8-
let x = ((if "age" then true else false)[@ns.braces ][@ns.ternary ])
9-
let x = (("age" |. Js.log; (let foo = 1 in let bar = 2 in foo + bar))
5+
let x = (({js|age|js})[@ns.braces ])
6+
let x = (({js|age|js}.(0))[@ns.braces ])
7+
let x = (({js|age|js} |. Js.log)[@ns.braces ])
8+
let x = ((if {js|age|js} then true else false)[@ns.braces ][@ns.ternary ])
9+
let x = (({js|age|js} |. Js.log; (let foo = 1 in let bar = 2 in foo + bar))
1010
[@ns.braces ])
1111
let x =
12-
((((if "age" then true else false)
12+
((((if {js|age|js} then true else false)
1313
[@ns.ternary ]);
1414
(let foo = 1 in let bar = 2 in foo + bar))
1515
[@ns.braces ])
16-
let x = (("age".(0); (let foo = 1 in let bar = 2 in foo + bar))[@ns.braces ])
16+
let x = (({js|age|js}.(0); (let foo = 1 in let bar = 2 in foo + bar))
17+
[@ns.braces ])

tests/parsing/grammar/expressions/expected/jsx.res.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,24 +491,24 @@ let _ =
491491
((button ?id:((id)[@ns.namedArgLoc ])
492492
~className:((Cn.make [|{js|button|js};{js|is-fullwidth|js}|])
493493
[@ns.namedArgLoc ][@ns.braces ]) ~onClick:((onClick)[@ns.namedArgLoc ])
494-
~children:[(("Submit" |> ste)[@ns.braces ])] ())
494+
~children:[(({js|Submit|js} |> ste)[@ns.braces ])] ())
495495
[@JSX ])
496496
let _ =
497497
((button ?id:((id)[@ns.namedArgLoc ])
498498
~className:((Cn.make [{js|button|js}; {js|is-fullwidth|js}])
499499
[@ns.namedArgLoc ][@ns.braces ]) ~onClick:((onClick)[@ns.namedArgLoc ])
500-
~children:[(("Submit" |> ste)[@ns.braces ])] ())
500+
~children:[(({js|Submit|js} |> ste)[@ns.braces ])] ())
501501
[@JSX ])
502502
let _ =
503503
((button ?id:((id)[@ns.namedArgLoc ])
504504
~className:((Cn.make ({js|button|js}, {js|is-fullwidth|js}))
505505
[@ns.namedArgLoc ][@ns.braces ]) ~onClick:((onClick)[@ns.namedArgLoc ])
506-
~children:[(("Submit" |> ste)[@ns.braces ])] ())
506+
~children:[(({js|Submit|js} |> ste)[@ns.braces ])] ())
507507
[@JSX ])
508508
let _ =
509509
((button ?id:((id)[@ns.namedArgLoc ]) ~className:((Cn.make { a = b })
510510
[@ns.namedArgLoc ][@ns.braces ]) ~onClick:((onClick)[@ns.namedArgLoc ])
511-
~children:[(("Submit" |> ste)[@ns.braces ])] ())
511+
~children:[(({js|Submit|js} |> ste)[@ns.braces ])] ())
512512
[@JSX ])
513513
let _ =
514514
((X.createElement ~y:((z |. (Belt.Option.getWithDefault {js||js}))

0 commit comments

Comments
 (0)