[Issue 5281] Equality among arrays of Bigints
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Dec 1 23:57:36 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5281
Don <clugdbug at yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch, wrong-code
CC| |clugdbug at yahoo.com.au
Depends on| |3659
Severity|normal |critical
--- Comment #2 from Don <clugdbug at yahoo.com.au> 2010-12-01 23:56:02 PST ---
This is difficult. The patch (below) fixes the problem, and I believe it's
correct. The problem is, that applying it causes Phobos to break, because it
has
been relying on this bug. And I don't know how to modify Phobos to fix it.
Specifically, Tuple and Variant are affected.
There's a cluster of bugs related to the problem, eg: bug 3659 ("Too much
exegesis on opEquals", bug 3607 "Problems with struct opEquals and const").
But the major problem is that with a const ref signature, opEquals cannot
perform comparisons with rvalues. So the code below fails
----
struct Foo
{
bool opEquals(ref const Foo f) const { return true; }
}
Foo foo()
{
Foo result;
return result;
}
void main()
{
Foo f;
// assert(f == foo()); // does not compile
}
----------
To make this patch work with the existing Phobos, while bug 3659 is not fixed,
change
if (!eq)
fdx->error("type signature should be %s not %s"
into
if (!eq && !td)
fdx->error("type signature should be %s not %s"
PATCH:
StructDeclaration::semantic in struct.c
Around line 503,
tfeqptr = new TypeFunction(parameters, Type::tbool, 0, LINKd);
tfeqptr->mod = MODconst;
tfeqptr = (TypeFunction *)tfeqptr->semantic(0, sc2);
Dsymbol *s = search_function(this, Id::eq);
FuncDeclaration *fdx = s ? s->isFuncDeclaration() : NULL;
+ TemplateDeclaration *td = s ? s->isTemplateDeclaration() : NULL;
+ if (td)
+ {
+ Expressions arguments;
+ arguments.setDim(1);
+ arguments.data[0] = (void*) param;
+ fdx = td->deduceFunctionTemplate(sc, loc, NULL, NULL, &arguments,
1);
+ }
if (fdx)
{
eq = fdx->overloadExactMatch(tfeqptr);
if (!eq)
fdx->error("type signature should be %s not %s",
tfeqptr->toChars(), fdx->type->toChars());
}
- TemplateDeclaration *td = s ? s->isTemplateDeclaration() : NULL;
- // BUG: should also check that td is a function template, not just a
template
- if (!eq && !td)
+ if (!eq)
eq = buildOpEquals(sc2);
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list