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

Bug #597234 reported by Eike on 2010-06-22
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Freeode
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) on 2010-06-22
Changed in freeode:
importance: Undecided → Critical
Eike (eike-welk) on 2010-06-22
description: updated
Eike (eike-welk) on 2010-06-25
Changed in freeode:
status: New → Confirmed
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) on 2010-07-10
tags: added: interpreter
Eike (eike-welk) on 2010-07-11
Changed in freeode:
milestone: none → 0.4.1
milestone: 0.4.1 → 0.4.2
Eike (eike-welk) wrote :
tags: added: expression
Eike (eike-welk) on 2010-11-07
description: updated
description: updated
Eike (eike-welk) on 2011-06-10
description: updated
Eike (eike-welk) on 2012-02-29
Changed in freeode:
assignee: nobody → Eike (eike-welk)
status: Confirmed → In Progress
description: updated
Eike (eike-welk) on 2012-04-03
description: updated
Eike (eike-welk) on 2012-04-03
description: updated
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers