Interpreter.eval_NodeAttrAccess must be able to look up attributes of unevaluated expressions.

Bug #597234 reported by Eike
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Freeode
In Progress
Critical
Eike

Bug Description

Interpreter.eval_NodeAttrAccess must be able to look up attributes of unevaluated expressions.

It seems there is a test case missing to test this feature. This is needed for print.

Expressions that should trigger the bug are:
data a, b: Float variable
 print(sqrt(a))
 print(a + b)
 (a + b).__add__(2)

data a, b: Float variable
print(sqrt(a))
print(a + b)
(a + b).__add__(2)
An other related 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_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.

See also:
 * Bug #672227 - New architecture for code generation in expressions
 * NewCodeGenerationArchitecture

http://sourceforge.net/apps/trac/freeode/ticket/7

Eike (eike-welk)
Changed in freeode:
importance: Undecided → Critical
Eike (eike-welk)
description: updated
Eike (eike-welk)
Changed in freeode:
status: New → Confirmed
Revision history for this message
Eike (eike-welk) wrote :

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_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.

Eike (eike-welk)
tags: added: interpreter
Eike (eike-welk)
Changed in freeode:
milestone: none → 0.4.1
milestone: 0.4.1 → 0.4.2
Revision history for this message
Eike (eike-welk) wrote :
tags: added: expression
Eike (eike-welk)
description: updated
description: updated
Eike (eike-welk)
description: updated
Eike (eike-welk)
Changed in freeode:
assignee: nobody → Eike (eike-welk)
status: Confirmed → In Progress
description: updated
Eike (eike-welk)
description: updated
Eike (eike-welk)
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.