http://d.puremagic.com/issues/show_bug.cgi?id=4004
Don clugd...@yahoo.com.au changed:
What|Removed |Added
Keywords||patch
CC||clugd...@yahoo.com.au
--- Comment #1 from Don clugd...@yahoo.com.au 2010-03-26 12:09:15 PDT ---
Reduced test case for test suite.
void bug4004a(ref int a) {
assert(a==7);
a+=3;
}
void bug4004b(ref int b) {
b= 7;
bug4004a(b);
}
int bug4004c() {
int offset = 5;
bug4004b(offset);
return offset;
}
static assert(bug4004c()==10);
-
PATCH:
Index: interpret.c
===
--- interpret.c(revision 420)
+++ interpret.c(working copy)
@@ -53,7 +53,7 @@
Expression *interpret_values(InterState *istate, Expression *earg,
FuncDeclaration *fd);
ArrayLiteralExp *createBlockDuplicatedArrayLiteral(Type *type, Expression
*elem, size_t dim);
-Expression * resolveReferences(Expression *e, Expression *thisval);
+Expression * resolveReferences(Expression *e, Expression *thisval, bool
*isReference = NULL);
/*
* Attempt to interpret a function given the arguments.
@@ -1107,8 +1107,11 @@
// -
// The variable used in a dotvar, index, or slice expression,
// after 'out', 'ref', and 'this' have been removed.
-Expression * resolveReferences(Expression *e, Expression *thisval)
+// *isReference will be set to true if a reference was removed.
+Expression * resolveReferences(Expression *e, Expression *thisval, bool
*isReference /*=NULL */)
{
+if (isReference)
+*isReference = false;
for(;;)
{
if (e-op == TOKthis)
@@ -1131,6 +1134,8 @@
VarExp *ve2 = (VarExp *)v-value;
if (!ve2-var-isSymbolDeclaration())
{
+if (isReference)
+*isReference = true;
e = v-value;
continue;
}
@@ -2087,7 +2092,8 @@
v-value = e2;
return e2;
}
-e1 = resolveReferences(e1, istate-localThis);
+bool destinationIsReference = false;
+e1 = resolveReferences(e1, istate-localThis, destinationIsReference);
// Unless we have a simple var assignment, we're
// only modifying part of the variable.
@@ -2167,7 +2174,8 @@
{
VarExp *ve = (VarExp *)e1;
VarDeclaration *v = ve-var-isVarDeclaration();
-addVarToInterstate(istate, v);
+if (!destinationIsReference)
+addVarToInterstate(istate, v);
v-value = newval;
}
else if (e1-op == TOKindex)
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---