painless: Fix issue with dup and cast
This commit is contained in:
parent
65aca4f71c
commit
3a5ef68ad0
|
@ -234,15 +234,16 @@ public final class EChain extends AExpression {
|
|||
final ADefLink lastDef = (ADefLink) last;
|
||||
expression.analyze(settings, definition, variables);
|
||||
lastDef.storeValueType = expression.expected = expression.actual;
|
||||
actual = read ? lastDef.storeValueType : definition.voidType;
|
||||
} else {
|
||||
// otherwise we adapt the type of the expression to the store type
|
||||
expression.expected = last.after;
|
||||
expression.analyze(settings, definition, variables);
|
||||
actual = read ? last.after : definition.voidType;
|
||||
}
|
||||
expression = expression.cast(settings, definition, variables);
|
||||
|
||||
statement = true;
|
||||
actual = read ? last.after : definition.voidType;
|
||||
}
|
||||
|
||||
private void analyzeRead() {
|
||||
|
|
|
@ -62,6 +62,14 @@ public class ArrayTests extends ScriptTestCase {
|
|||
assertEquals(6, exec("def x = new int[5]; x[0] = 5; x[0]++; return x[0];"));
|
||||
}
|
||||
|
||||
public void testJacksCrazyExpression1() {
|
||||
assertEquals(1, exec("int x; def[] y = new def[1]; x = y[0] = 1; return x;"));
|
||||
}
|
||||
|
||||
public void testJacksCrazyExpression2() {
|
||||
assertEquals(1, exec("int x; def y = new def[1]; x = y[0] = 1; return x;"));
|
||||
}
|
||||
|
||||
public void testForLoop() {
|
||||
assertEquals(999*1000/2, exec("def a = new int[1000]; for (int x = 0; x < a.length; x++) { a[x] = x; } "+
|
||||
"int total = 0; for (int x = 0; x < a.length; x++) { total += a[x]; } return total;"));
|
||||
|
|
Loading…
Reference in New Issue