You can look up attributes of the ast.Node itself:
(a + b).function
or
(a + b).loc
This should off course not be possible. Therefore unevaluated expressions need special treatment in Interpreter.eval_NodeAttrAccess(...).
A safe treatment of this situation is:
- Create a variable of the right type and role, and assign the expression to it.
- Do attribute lookups with this variable.
- Optimize the variable away later.
Nearly all lookups are however for methods. They can be processed without constructing an intermediate variable.
An other issue:
You can look up attributes of the ast.Node itself:
(a + b).function
or
(a + b).loc
This should off course not be possible. Therefore unevaluated expressions need special treatment in Interpreter. eval_NodeAttrAc cess(.. .).
A safe treatment of this situation is:
- Create a variable of the right type and role, and assign the expression to it.
- Do attribute lookups with this variable.
- Optimize the variable away later.
Nearly all lookups are however for methods. They can be processed without constructing an intermediate variable.