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

Revert "jsx: allow locally abstract types and type constraints on @react.component definitions (#487)" #488

Merged
merged 1 commit into from
May 8, 2022
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
11 changes: 3 additions & 8 deletions src/reactjs_jsx_ppx_v3.ml
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@ let otherAttrsPure (loc, _) = loc.txt <> "react.component"
let hasAttrOnBinding { pvb_attributes } = find_opt hasAttr pvb_attributes <> None

(* Finds the name of the variable the binding is assigned to, otherwise raises Invalid_argument *)
let rec getFnName binding =
let getFnName binding =
match binding with
| { ppat_desc = Ppat_var { txt } } -> txt
| { ppat_desc = Ppat_constraint (pat, _) } -> getFnName pat
| { pvb_pat = { ppat_desc = Ppat_var { txt } } } -> txt
| _ -> raise (Invalid_argument "react.component calls cannot be destructured.")
[@@raises Invalid_argument]

Expand Down Expand Up @@ -488,7 +487,7 @@ let jsxMapper () =
let bindingLoc = binding.pvb_loc in
let bindingPatLoc = binding.pvb_pat.ppat_loc in
let binding = { binding with pvb_pat = { binding.pvb_pat with ppat_loc = emptyLoc }; pvb_loc = emptyLoc } in
let fnName = getFnName binding.pvb_pat in
let fnName = getFnName binding in
let internalFnName = fnName ^ "$Internal" in
let fullModuleName = makeModuleName fileName !nestedModules fnName in
let modifiedBindingOld binding =
Expand All @@ -507,10 +506,6 @@ let jsxMapper () =
spelunkForFunExpression innerFunctionExpression
| { pexp_desc = Pexp_sequence (_wrapperExpression, innerFunctionExpression) } ->
spelunkForFunExpression innerFunctionExpression
| { pexp_desc = Pexp_newtype (_label, innerFunctionExpression) } ->
spelunkForFunExpression innerFunctionExpression
| { pexp_desc = Pexp_constraint (innerFunctionExpression, _typ) } ->
spelunkForFunExpression innerFunctionExpression
| _ ->
raise
(Invalid_argument
Expand Down
6 changes: 0 additions & 6 deletions tests/ppx/react/expected/newtype.res.txt

This file was deleted.

8 changes: 0 additions & 8 deletions tests/ppx/react/expected/typeConstraint.res.txt

This file was deleted.

2 changes: 0 additions & 2 deletions tests/ppx/react/newtype.res

This file was deleted.

2 changes: 0 additions & 2 deletions tests/ppx/react/typeConstraint.res

This file was deleted.