diff --git a/infer/tests/codetoanalyze/hack/pulse/abstractconstants.hack b/infer/tests/codetoanalyze/hack/pulse/abstractconstants.hack new file mode 100644 index 00000000000..1ccbbb4bcf3 --- /dev/null +++ b/infer/tests/codetoanalyze/hack/pulse/abstractconstants.hack @@ -0,0 +1,38 @@ +// Copyright (c) Facebook, Inc. and its affiliates. +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. + +// check we resolve constants in the right order + +namespace AbstractConstants; + +abstract class C { + abstract const int MyC; +} + +interface I { + const int MyC = 1; +} + +trait T { + const int MyC = 2; +} + +class D extends C implements I { + +} + +class E extends C { + use T; +} + +class Tester { + public static function constant_from_interface_FP(): void { + D::MyC; + } + + public static function constant_from_trait_OK(): void { + E::MyC; + } +} diff --git a/infer/tests/codetoanalyze/hack/pulse/issues.exp b/infer/tests/codetoanalyze/hack/pulse/issues.exp index e3db6aabd22..ac6c5fef46c 100644 --- a/infer/tests/codetoanalyze/hack/pulse/issues.exp +++ b/infer/tests/codetoanalyze/hack/pulse/issues.exp @@ -1,3 +1,4 @@ +abstractconstants.hack, AbstractConstants::Tester$static.constant_from_interface_FP, 1, PULSE_UNINITIALIZED_CONST, no_bucket, ERROR, [global variable `AbstractConstants::C$static` accessed here,read to uninitialized value occurs here] aliases.hack, Aliases::C.testAliasedShapeReturnBad, 3, PULSE_UNAWAITED_AWAITABLE, no_bucket, ERROR, [allocation part of the trace starts here,allocated by async call here,awaitable becomes unreachable here] aliases.hack, Aliases::C.testParameterAliasOK_FP, 5, PULSE_UNAWAITED_AWAITABLE, no_bucket, ERROR, [allocation part of the trace starts here,allocated by async call here,awaitable becomes unreachable here] arg_index_matcher.hack, Main.staticSink, 2, TAINT_ERROR, no_bucket, ERROR, [in call to `ArgIndexMatcher$static.source`,source of the taint here: value returned from `$root.Level1::taintSource` with kind `Simple`,return from call to `ArgIndexMatcher$static.source`,flows to this sink: value passed as argument `#1` to `ArgIndexMatcher$static.sink1` with kind `Simple`], source: $root.Level1::taintSource, sink: ArgIndexMatcher$static.sink1, tainted expression: $tainted