From 527a1dc8e73e7e1d0015d8e5d650c760f0062731 Mon Sep 17 00:00:00 2001 From: Mistral Contrastin Date: Fri, 24 Jan 2025 09:53:08 -0800 Subject: [PATCH] Eliminate false positives on unsurfaced lambda Summary: Lints are check on TASTs both under normal and dynamic assumptions. Unsurfaced exception lint was producing false positives because the `dynamic` run had all lambdas replaced with `Omitted` expressions and the lint rule relies on finding references to the exception binding. This diff opts the lint into sound linting which means that we require an agreement between the normal and dynamic pass. Since no lint is produced in the normal pass, the false positives are prevented. Reviewed By: andrewjkennedy Differential Revision: D68631579 fbshipit-source-id: 38efae1606fdc37250cb33e41da566183b2962f4 --- .../test/lint/unsurfaced_exception_lambda.good.php | 11 +++++++++++ .../lint/unsurfaced_exception_lambda.good.php.exp | 1 + 2 files changed, 12 insertions(+) create mode 100644 hphp/hack/test/lint/unsurfaced_exception_lambda.good.php create mode 100644 hphp/hack/test/lint/unsurfaced_exception_lambda.good.php.exp diff --git a/hphp/hack/test/lint/unsurfaced_exception_lambda.good.php b/hphp/hack/test/lint/unsurfaced_exception_lambda.good.php new file mode 100644 index 0000000000000..d589d05cbb12c --- /dev/null +++ b/hphp/hack/test/lint/unsurfaced_exception_lambda.good.php @@ -0,0 +1,11 @@ + {} + +function unsurfaced_exception_lambda_good(Box $_): void { + try { + 42; + } catch (Exception $ex) { + () ==> $ex; + } +} diff --git a/hphp/hack/test/lint/unsurfaced_exception_lambda.good.php.exp b/hphp/hack/test/lint/unsurfaced_exception_lambda.good.php.exp new file mode 100644 index 0000000000000..3727f7d02538c --- /dev/null +++ b/hphp/hack/test/lint/unsurfaced_exception_lambda.good.php.exp @@ -0,0 +1 @@ +No lint errors