Open bart1e opened 1 year ago
After giving it more thought, I think that it might be a correct Slither
behaviour, because g
in this case belongs to the contract B
(since it inherits from A
), but is defined in the A.sol
, so source_mapping
cannot point to some code in B.sol
. Hence, in fact, there is no better candidate for source_mapping
here.
If this is the case, then the issue may be closed.
@bart1e Is this different from what is outlined here https://github.com/crytic/slither/blob/4c976d5af56219eeef079e03a35009af3e03644d/slither/solc_parsing/expressions/find_variable.py#L420-L439
@0xalpharush I think it's sligthly different since I was referring to the use (not the declaration) of function f
in g
in the example I gave.
It was confusing to me since it seemed strange that a function from file A can reference function from file B, when file A doesn't import B.
But when I think about it, there is just no better candidate for reference of the function f
from my example. So, while it was confusing at first, I think now that this is correct behaviour of Slither
.
Describe the issue:
Suppose that we have a contract
A
defined inA.sol
that has a virtual functionf
and a (normal) functiong
that usesf
. Additionally, there is a contractB
inheriting fromA
and overridingf
.Then,
references
list forB.f
contains a code fromA.sol
(the line wheref
is referenced ing
).Here is the code fragment that updates
references
list: https://github.com/crytic/slither/blob/3383e39823a088fc00c6a2563ba23ac202b29c39/slither/solc_parsing/expressions/expression_parsing.py#L465-L467In this case,
identifier.source_mapping
will reference a fragment ofg
function fromA.sol
andreferences
list will be updated incorrectly.Code example to reproduce the issue:
Version:
0.9.2
Relevant log output:
No response