-
Notifications
You must be signed in to change notification settings - Fork 2
Better handling of nester context #22
Copy link
Copy link
Open
Labels
duplicateThis issue or pull request already existsThis issue or pull request already existsenhancementNew feature or requestNew feature or request
Description
This will be a large MR.
Currently rattr does not properly handle comprehensions and nested functions.
def fn(a):
def inner(b):
b.attr = 4
return inner(a)The above code snippet should give a.attr in the results but it gives b.attr. This is because functions are followed using the functions present in the function IR (i.e. the functions defined in the root context). The same problem is present for the contexts within list comprehensions for example:
[a.attr for a in thing]should give thing.a[].attr in the results.
This could be achieved by storing the definitions and calls to functions under more specific names, such as fn:inner:<lineno> rather than inner. This should be generalised to handle anonymous lambdas (though only under certain circumstances).
NOTE
Possible duplicate of, or overlap with, #4
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
duplicateThis issue or pull request already existsThis issue or pull request already existsenhancementNew feature or requestNew feature or request