Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

Alias analysis for purity detection #297

Open
lukarade opened this issue Aug 30, 2024 · 0 comments
Open

Alias analysis for purity detection #297

lukarade opened this issue Aug 30, 2024 · 0 comments
Labels
enhancement 💡 New feature or request purity Inferring the purity of functions

Comments

@lukarade
Copy link
Contributor

lukarade commented Aug 30, 2024

Is your feature request related to a problem?

Right now, the following cases cannot be handled by the purity analysis.
Calling dtype, is_list_like, _recurse or fspath will result in an UnknownCall being added as a reason for impurity.

# Case 1
import np
dtype = np.dtype(dtype) 

import lib
is_list_like = lib.is_list_like 

# Case 2
def _replace_dtype_fields_recursive(dtype, primitive_dtype):
    "Private function allowing recursion in _replace_dtype_fields."
    _recurse = _replace_dtype_fields_recursive
    ...

# Case 3
# inside os module
if not _exists('fspath'):
    fspath = _fspath
    fspath.__name__ = "fspath"

def _fspath(path):
    """Return the path representation of a path-like object."""
    ...

In case 1 the called symbol is an alias for an imported function.
In case 2 the called symbol is a "private" alias inside the function to enable recursion.
In case 3 the function is renamed and then called via its alias.

Desired solution

To increase the precision of the purity analysis, these cases should be considerate in more depth.
This could be done by implementing an alias analysis into the purity analysis, which can identify pairs of variables and fields which are referencing the same object and therefore can be treated as aliases.

Possible alternatives (optional)

No response

Screenshots (optional)

No response

Additional Context (optional)

These examples were collected by manually analyzing the reasons for the function safeds.data.tabular.containers._table.from_csv_file.
Manual_reasons_analysis_for-safeds.data.tabular.containers._table.from_csv_file.xlsx

@lukarade lukarade added enhancement 💡 New feature or request purity Inferring the purity of functions labels Aug 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement 💡 New feature or request purity Inferring the purity of functions
Projects
Status: Backlog
Development

No branches or pull requests

1 participant