Add decl_errors field to folded class definition
commit2dcc5bedf70cf97ceb26cf63a105ba66a5d2fbe1
authorThomas Jiang <thomasjiang@fb.com>
Tue, 8 Mar 2022 21:26:50 +0000 (8 13:26 -0800)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Tue, 8 Mar 2022 21:26:50 +0000 (8 13:26 -0800)
tree5ecec085b5fb4f1b1cddd0a6d5162086909df474
parent24fe174c112bc48042f4e83e588e769d56a29cc9
Add decl_errors field to folded class definition

Summary:
Errors in the decl folding process are handled interestingly. I believe the following is happening:

Errors are being thrown as they are in the normal typechecking step, by adding the error to global state.

https://www.internalfb.com/code/fbsource/[f738d273de54]/fbcode/hphp/hack/src/decl/decl_folded_class.ml?lines=112-129

Those errors that are added during the `class_decl` step are then captured in this `Errors.do_` and then added to the `dc_decl_errors` field in the folded decl.

https://www.internalfb.com/code/fbsource/[4b5de3c992492ee6a53d96f71bcea06f9decc7fc]/fbcode/hphp/hack/src/decl/decl_folded_class.ml?lines=785-790

So, as an attempt to not go down this path, this diff attempts to just collect the errors locally.

The `decl_errors` field is currently a `Box<[TypingError]>`, which I'm not entirely sure is a direct match with the OCaml version of the field which is `Errors.t option` which is `(error files_t) option` which is `(error file_t Relative_path.Map.t) option` which is `error list PhaseMap.t Relative_path.Map.t option`.

So... Not entirely sure what a more representative data structure for that would be.

Reviewed By: shayne-fletcher

Differential Revision: D34539432

fbshipit-source-id: 402ec4a4589537e6048c58969e36be2edfc30202
hphp/hack/src/rupro/lib/decl_defs/debug.rs
hphp/hack/src/rupro/lib/decl_defs/folded.rs
hphp/hack/src/rupro/lib/folded_decl_provider/fold.rs
hphp/hack/src/rupro/lib/typing_error/error_primary.rs
hphp/hack/test/rupro/folded_decls/trait_reuse1.php [new file with mode: 0644]
hphp/hack/test/rupro/folded_decls/trait_reuse1.php.folded_decls.exp [new file with mode: 0644]