Safe-DS / Library-Analyzer

Analysis of Python libraries and of code that uses them.
https://library-analyzer.safeds.com
MIT License
5 stars 0 forks source link

Missing `NonLocalVariableRead` and `NonLocalVariableWrite` in `@property` functions #300

Open lukarade opened 2 months ago

lukarade commented 2 months ago

Describe the bug

In (some) @property functions, the access to other properties of the class are not detected as reasons for impurity.

Examples:

# seaborn_v0.12.2.external.version.is_devrelease.334.4
@property
def is_devrelease(self) -> bool:
    return self.dev is not None # Impure Read from property dev is not detected
# pandas_v2.0.3.core.arrays.sparse.array.nbytes.667.4
@property
def nbytes(self) -> int:
    return self.sp_values.nbytes + self.sp_index.nbytes # Impure Read from property sp_values and sp_index is not detected

To Reproduce

  1. Run purity analysis on the libraries
  2. Check the result file

Expected behavior

Access of propertys are impure and therefore must be detected as impure. Therefore a special case needs to be implemented to deal with that.

Screenshots (optional)

No response

Additional Context (optional)

Since the tests were only done for a sample of functions, there could be more functions with the same problem.