Heuristic vs. Actual Return Value
Why to use heuristic, if we can directly see the method actual return value?
It's possible to find the actual return value. To do this, the tool would need to:
- See the call P2shAddress.from_script.
- Use the imports_map to find the file where P2shAddress is defined (e.g., /path/to/bitcoinutils/keys.py).
- Pause its current work, open and parse keys.py into a new AST.
- Search that new AST for the ClassDef named P2shAddress.
- Search within that class for the FunctionDef named from_script.
- Analyze the code inside from_script to find its return statement(s) and determine what type is being returned (e.g., by seeing return cls(...)).
This is a much more complex and "heavy" operation than simply analyzing one file at a time. The "heuristic" (ClassName.method() likely returns an instance of ClassName) is a lightweight shortcut. It's not 100% accurate (a method could return something else), but it's extremely fast and covers the vast majority of real-world object-oriented code.
Reproducible by cloning python-bitcoin-utils and analyzing the file 'create_p2sh_csv_p2pkh_address.py'
Heuristic vs. Actual Return Value
Why to use heuristic, if we can directly see the method actual return value?
It's possible to find the actual return value. To do this, the tool would need to:
This is a much more complex and "heavy" operation than simply analyzing one file at a time. The "heuristic" (ClassName.method() likely returns an instance of ClassName) is a lightweight shortcut. It's not 100% accurate (a method could return something else), but it's extremely fast and covers the vast majority of real-world object-oriented code.
Reproducible by cloning python-bitcoin-utils and analyzing the file 'create_p2sh_csv_p2pkh_address.py'