Skip to content

Commit

Permalink
[impurity] Add test to showcase double report on impure static functions
Browse files Browse the repository at this point in the history
Summary: Currently we're reporting both $static object and wrapper functions which is excessive.

Reviewed By: davidpichardie

Differential Revision:
D60589822

Privacy Context Container: L1208441

fbshipit-source-id: 9cece4013d766fc0ddfbc469d521fed6b7da09eb
  • Loading branch information
geralt-encore authored and facebook-github-bot committed Aug 1, 2024
1 parent f1b4d6f commit 5b8a7b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions infer/tests/codetoanalyze/hack/impurity/basic.hack
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ class Object {
$obj->a = $i;
}

public static function staticParameterFieldWriteImpure(
Object $obj,
int $i,
): void {
$obj->a = $i;
}

public function parameterFieldAccessPure(Object $obj): int {
return $obj->a;
}
Expand Down
2 changes: 2 additions & 0 deletions infer/tests/codetoanalyze/hack/impurity/issues.exp
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ basic.hack, Basic::Object.__construct, 0, IMPURE_FUNCTION, no_bucket, ERROR, [Im
basic.hack, Basic::Object.setImpure, 0, IMPURE_FUNCTION, no_bucket, ERROR, [Impure function Basic::Object.setImpure,parameter `$this.*a` modified here]
basic.hack, Basic::Object.callImpureImpure, 0, IMPURE_FUNCTION, no_bucket, ERROR, [Impure function Basic::Object.callImpureImpure,when calling `Basic::Object.setImpure` here,parameter `$this.*a` modified here]
basic.hack, Basic::Object.parameterFieldWriteImpure, 0, IMPURE_FUNCTION, no_bucket, ERROR, [Impure function Basic::Object.parameterFieldWriteImpure,parameter `$obj.*a` modified here]
basic.hack, Basic::Object$static.staticParameterFieldWriteImpure, 0, IMPURE_FUNCTION, no_bucket, ERROR, [Impure function Basic::Object$static.staticParameterFieldWriteImpure,parameter `$obj.*a` modified here]
basic.hack, Basic::Object.staticParameterFieldWriteImpure, 0, IMPURE_FUNCTION, no_bucket, ERROR, [Impure function Basic::Object.staticParameterFieldWriteImpure,when calling `Basic::Object$static.staticParameterFieldWriteImpure` here,parameter `$obj.*a` modified here]
basic.hack, Basic::Object.swapImpure, 0, IMPURE_FUNCTION, no_bucket, ERROR, [Impure function Basic::Object.swapImpure,parameter `$vec.*__infer_model_backing_last_read` modified here]

0 comments on commit 5b8a7b4

Please sign in to comment.