-
Notifications
You must be signed in to change notification settings - Fork 470
Pass existing location to children prop #7540
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
Draft
nojaf
wants to merge
4
commits into
rescript-lang:master
Choose a base branch
from
nojaf:jsx-ast-children-loc
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,21 +23,6 @@ | |
addValueReference ComponentAsProp.res:12:24 --> ComponentAsProp.res:12:13 | ||
addValueReference ComponentAsProp.res:13:16 --> React.res:3:0 | ||
addValueReference ComponentAsProp.res:11:14 --> ComponentAsProp.res:6:34 | ||
addValueReference ComponentAsProp.res:9:6 --> ComponentAsProp.res:6:12 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zth, any thoughts on whether this is problematic or not? |
||
addValueReference ComponentAsProp.res:10:6 --> ComponentAsProp.res:6:20 | ||
addValueReference ComponentAsProp.res:12:24 --> ComponentAsProp.res:12:13 | ||
addValueReference ComponentAsProp.res:13:16 --> React.res:3:0 | ||
addValueReference ComponentAsProp.res:11:14 --> ComponentAsProp.res:6:34 | ||
addValueReference ComponentAsProp.res:9:6 --> ComponentAsProp.res:6:12 | ||
addValueReference ComponentAsProp.res:10:6 --> ComponentAsProp.res:6:20 | ||
addValueReference ComponentAsProp.res:12:24 --> ComponentAsProp.res:12:13 | ||
addValueReference ComponentAsProp.res:13:16 --> React.res:3:0 | ||
addValueReference ComponentAsProp.res:11:14 --> ComponentAsProp.res:6:34 | ||
addValueReference ComponentAsProp.res:9:6 --> ComponentAsProp.res:6:12 | ||
addValueReference ComponentAsProp.res:10:6 --> ComponentAsProp.res:6:20 | ||
addValueReference ComponentAsProp.res:12:24 --> ComponentAsProp.res:12:13 | ||
addValueReference ComponentAsProp.res:13:16 --> React.res:3:0 | ||
addValueReference ComponentAsProp.res:11:14 --> ComponentAsProp.res:6:34 | ||
addTypeReference _none_:1:-1 --> ComponentAsProp.res:6:12 | ||
addTypeReference _none_:1:-1 --> ComponentAsProp.res:6:20 | ||
addTypeReference _none_:1:-1 --> ComponentAsProp.res:6:34 | ||
|
@@ -422,52 +407,17 @@ | |
addValueReference Hooks.res:10:29 --> Hooks.res:4:12 | ||
addValueReference Hooks.res:10:75 --> Hooks.res:5:7 | ||
addValueReference Hooks.res:9:7 --> React.res:7:0 | ||
addTypeReference Hooks.res:10:29 --> Hooks.res:1:16 | ||
addValueReference Hooks.res:10:29 --> Hooks.res:4:12 | ||
addValueReference Hooks.res:10:75 --> Hooks.res:5:7 | ||
addValueReference Hooks.res:9:7 --> React.res:7:0 | ||
addValueReference Hooks.res:13:54 --> React.res:7:0 | ||
addValueReference Hooks.res:13:54 --> React.res:7:0 | ||
addValueReference Hooks.res:13:40 --> Hooks.res:5:7 | ||
addValueReference Hooks.res:13:26 --> Hooks.res:5:14 | ||
addValueReference Hooks.res:14:5 --> ImportHooks.res:13:0 | ||
addValueReference Hooks.res:15:7 --> React.res:7:0 | ||
addValueReference Hooks.res:15:32 --> React.res:7:0 | ||
addValueReference Hooks.res:15:7 --> React.res:7:0 | ||
addValueReference Hooks.res:15:32 --> React.res:7:0 | ||
addValueReference Hooks.res:14:76 --> Hooks.res:14:57 | ||
addValueReference Hooks.res:14:63 --> React.res:7:0 | ||
addValueReference Hooks.res:17:5 --> ImportHookDefault.res:6:0 | ||
addValueReference Hooks.res:19:7 --> React.res:7:0 | ||
addValueReference Hooks.res:19:32 --> React.res:7:0 | ||
addValueReference Hooks.res:19:7 --> React.res:7:0 | ||
addValueReference Hooks.res:19:32 --> React.res:7:0 | ||
addValueReference Hooks.res:18:74 --> Hooks.res:18:55 | ||
addValueReference Hooks.res:18:61 --> React.res:7:0 | ||
addTypeReference Hooks.res:10:29 --> Hooks.res:1:16 | ||
addValueReference Hooks.res:10:29 --> Hooks.res:4:12 | ||
addValueReference Hooks.res:10:75 --> Hooks.res:5:7 | ||
addValueReference Hooks.res:9:7 --> React.res:7:0 | ||
addTypeReference Hooks.res:10:29 --> Hooks.res:1:16 | ||
addValueReference Hooks.res:10:29 --> Hooks.res:4:12 | ||
addValueReference Hooks.res:10:75 --> Hooks.res:5:7 | ||
addValueReference Hooks.res:9:7 --> React.res:7:0 | ||
addValueReference Hooks.res:13:54 --> React.res:7:0 | ||
addValueReference Hooks.res:13:54 --> React.res:7:0 | ||
addValueReference Hooks.res:13:40 --> Hooks.res:5:7 | ||
addValueReference Hooks.res:13:26 --> Hooks.res:5:14 | ||
addValueReference Hooks.res:14:5 --> ImportHooks.res:13:0 | ||
addValueReference Hooks.res:15:7 --> React.res:7:0 | ||
addValueReference Hooks.res:15:32 --> React.res:7:0 | ||
addValueReference Hooks.res:15:7 --> React.res:7:0 | ||
addValueReference Hooks.res:15:32 --> React.res:7:0 | ||
addValueReference Hooks.res:14:76 --> Hooks.res:14:57 | ||
addValueReference Hooks.res:14:63 --> React.res:7:0 | ||
addValueReference Hooks.res:17:5 --> ImportHookDefault.res:6:0 | ||
addValueReference Hooks.res:19:7 --> React.res:7:0 | ||
addValueReference Hooks.res:19:32 --> React.res:7:0 | ||
addValueReference Hooks.res:19:7 --> React.res:7:0 | ||
addValueReference Hooks.res:19:32 --> React.res:7:0 | ||
addValueReference Hooks.res:18:74 --> Hooks.res:18:55 | ||
addValueReference Hooks.res:18:61 --> React.res:7:0 | ||
addTypeReference _none_:1:-1 --> Hooks.res:4:12 | ||
|
@@ -478,21 +428,14 @@ | |
addTypeReference Hooks.res:29:66 --> Hooks.res:1:16 | ||
addValueReference Hooks.res:29:66 --> Hooks.res:29:14 | ||
addValueReference Hooks.res:29:34 --> React.res:7:0 | ||
addTypeReference Hooks.res:29:66 --> Hooks.res:1:16 | ||
addValueReference Hooks.res:29:66 --> Hooks.res:29:14 | ||
addValueReference Hooks.res:29:34 --> React.res:7:0 | ||
addTypeReference _none_:1:-1 --> Hooks.res:29:14 | ||
addRecordLabelDeclaration vehicle Hooks.res:33:16 path:+Hooks.Inner.Inner2.props | ||
addRecordLabelDeclaration vehicle Hooks.res:33:16 path:+Hooks.Inner.Inner2.props | ||
addTypeReference Hooks.res:33:68 --> Hooks.res:1:16 | ||
addValueReference Hooks.res:33:68 --> Hooks.res:33:16 | ||
addValueReference Hooks.res:33:36 --> React.res:7:0 | ||
addTypeReference Hooks.res:33:68 --> Hooks.res:1:16 | ||
addValueReference Hooks.res:33:68 --> Hooks.res:33:16 | ||
addValueReference Hooks.res:33:36 --> React.res:7:0 | ||
addTypeReference _none_:1:-1 --> Hooks.res:33:16 | ||
addValueReference Hooks.res:39:25 --> React.res:3:0 | ||
addValueReference Hooks.res:39:25 --> React.res:3:0 | ||
addTypeReference Hooks.res:47:2 --> Hooks.res:1:16 | ||
addValueReference Hooks.res:45:4 --> Hooks.res:45:31 | ||
addTypeReference Hooks.res:47:14 --> Hooks.res:1:16 | ||
|
11 changes: 11 additions & 0 deletions
11
tests/build_tests/super_errors/expected/missing_required_prop.res.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/missing_required_prop.res[0m:[2m28:7-37[0m | ||
|
||
26 [2m┆[0m let make = () => { | ||
27 [2m┆[0m <Wrapper> | ||
[1;31m28[0m [2m┆[0m [1;31m<div> {""->React.string} </div>[0m | ||
29 [2m┆[0m </Wrapper> | ||
30 [2m┆[0m } | ||
|
||
This JSX component does not accept child elements. It has no [1;31mchildren[0m prop [1;33m<Wrapper />[0m |
13 changes: 13 additions & 0 deletions
13
tests/build_tests/super_errors/expected/missing_required_prop_when_children.res.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/missing_required_prop_when_children.res[0m:[2m31:7-32:37[0m | ||
|
||
29 [2m┆[0m let make = () => { | ||
30 [2m┆[0m <Wrapper> | ||
[1;31m31[0m [2m┆[0m [1;31m<button> {"yo"->React.string} </button>[0m | ||
[1;31m32[0m [2m┆[0m [1;31m <div> {""->React.string} </div>[0m | ||
33 [2m┆[0m </Wrapper> | ||
34 [2m┆[0m } | ||
|
||
The component [1;33m<Wrapper />[0m is missing these required props: | ||
value |
12 changes: 12 additions & 0 deletions
12
tests/build_tests/super_errors/expected/missing_required_prop_when_single_child.res.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/missing_required_prop_when_single_child.res[0m:[2m28:7-37[0m | ||
|
||
26 [2m┆[0m let make = () => { | ||
27 [2m┆[0m <Wrapper> | ||
[1;31m28[0m [2m┆[0m [1;31m<div> {""->React.string} </div>[0m | ||
29 [2m┆[0m </Wrapper> | ||
30 [2m┆[0m } | ||
|
||
The component [1;33m<Wrapper />[0m is missing these required props: | ||
value |
31 changes: 31 additions & 0 deletions
31
tests/build_tests/super_errors/fixtures/missing_required_prop.res
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module React = { | ||
type element = Jsx.element | ||
@val external null: element = "null" | ||
type componentLike<'props, 'return> = Jsx.componentLike<'props, 'return> | ||
type component<'props> = Jsx.component<'props> | ||
external component: componentLike<'props, element> => component<'props> = "%identity" | ||
@module("react/jsx-runtime") | ||
external jsx: (component<'props>, 'props) => element = "jsx" | ||
external string: string => element = "%identity" | ||
} | ||
module ReactDOM = { | ||
external someElement: React.element => option<React.element> = "%identity" | ||
@module("react/jsx-runtime") | ||
external jsx: (string, JsxDOM.domProps) => Jsx.element = "jsx" | ||
} | ||
|
||
module Wrapper = { | ||
@react.component | ||
let make = (~value: 'value) => { | ||
<div> {React.null} </div> | ||
} | ||
} | ||
|
||
module SomeComponent = { | ||
@react.component | ||
let make = () => { | ||
<Wrapper> | ||
<div> {""->React.string} </div> | ||
</Wrapper> | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
tests/build_tests/super_errors/fixtures/missing_required_prop_when_children.res
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module React = { | ||
type element = Jsx.element | ||
@val external null: element = "null" | ||
type componentLike<'props, 'return> = Jsx.componentLike<'props, 'return> | ||
type component<'props> = Jsx.component<'props> | ||
external component: componentLike<'props, element> => component<'props> = "%identity" | ||
@module("react/jsx-runtime") | ||
external jsx: (component<'props>, 'props) => element = "jsx" | ||
@module("react/jsx-runtime") | ||
external jsxs: (component<'props>, 'props) => element = "jsxs" | ||
external string: string => element = "%identity" | ||
external array: array<element> => element = "%identity" | ||
} | ||
module ReactDOM = { | ||
external someElement: React.element => option<React.element> = "%identity" | ||
@module("react/jsx-runtime") | ||
external jsx: (string, JsxDOM.domProps) => Jsx.element = "jsx" | ||
} | ||
|
||
module Wrapper = { | ||
@react.component | ||
let make = (~value: 'value, ~children: React.element) => { | ||
<div> {children} </div> | ||
} | ||
} | ||
|
||
module SomeComponent = { | ||
@react.component | ||
let make = () => { | ||
<Wrapper> | ||
<button> {"yo"->React.string} </button> | ||
<div> {""->React.string} </div> | ||
</Wrapper> | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
tests/build_tests/super_errors/fixtures/missing_required_prop_when_single_child.res
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module React = { | ||
type element = Jsx.element | ||
@val external null: element = "null" | ||
type componentLike<'props, 'return> = Jsx.componentLike<'props, 'return> | ||
type component<'props> = Jsx.component<'props> | ||
external component: componentLike<'props, element> => component<'props> = "%identity" | ||
@module("react/jsx-runtime") | ||
external jsx: (component<'props>, 'props) => element = "jsx" | ||
external string: string => element = "%identity" | ||
} | ||
module ReactDOM = { | ||
external someElement: React.element => option<React.element> = "%identity" | ||
@module("react/jsx-runtime") | ||
external jsx: (string, JsxDOM.domProps) => Jsx.element = "jsx" | ||
} | ||
|
||
module Wrapper = { | ||
@react.component | ||
let make = (~value: 'value, ~children: React.element) => { | ||
<div> {children} </div> | ||
} | ||
} | ||
|
||
module SomeComponent = { | ||
@react.component | ||
let make = () => { | ||
<Wrapper> | ||
<div> {""->React.string} </div> | ||
</Wrapper> | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 3 additions & 18 deletions
21
tests/syntax_tests/data/ppx/react/expected/fragment.res.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this change is responsible for the changes in the dead code analysis. But this change does not seem necessary to fix the location issue in error messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have an explanation as to why this would happen. More non-dummy locations should lead to more value dependencies found in the dead code analysis, which just traverses the typed ast.
Unless, somehow, this change affects the locations produced during type inference.