After tracking this issue for a while, I believe this is a problem on the generated AST. Since I'm not very familiar with Jython's inner-workings, can anyone confirm this to me?
Take this example script:
a = 1
b = 2
(a + b)
(a + b).c = 3
The generated AST is:
('Module',
('body',
('Assign (1,0)',
('targets', ('Name (1,0)', ('id', 'a'), ('ctx', ('Store',)))),
('value', ('Num (1,4)', ('n', 1)))),
('Assign (2,0)',
('targets', ('Name (2,0)', ('id', 'b'), ('ctx', ('Store',)))),
('value', ('Num (2,4)', ('n', 2)))),
('Expr (3,0)',
('value',
('BinOp (3,1)',
('left', ('Name (3,1)', ('id', 'a'), ('ctx', ('Load',)))),
('op', ('Add',)),
('right', ('Name (3,5)', ('id', 'b'), ('ctx', ('Load',))))))),
('Assign (4,0)',
('targets',
('Attribute (4,0)',
('value',
('BinOp (4,1)',
('left', ('Name (4,1)', ('id', 'a'), ('ctx', ('Store',)))),
('op', ('Add',)),
('right', ('Name (4,5)', ('id', 'b'), ('ctx', ('Store',)))))),
('attr', 'c'),
('ctx', ('Store',)))),
('value', ('Num (4,12)', ('n', 3))))))
I believe the context from the last statement is wrong. Shouldn't it be using the Load context on the operands of BinOp (4,1)?
In case you're wondering, expressions like (~a).attr = b are also crashing Jython. |