Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #70 from 9rnsr/relax_opEquals_sig
Browse files Browse the repository at this point in the history
Supplemental changes of dmd/pull/373
  • Loading branch information
jmdavis committed Sep 30, 2011
2 parents 9dca50f + 4ee5dae commit 2c06a00
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 2 additions & 0 deletions import/object.di
Expand Up @@ -503,5 +503,7 @@ bool _ArrayEq(T1, T2)(T1[] a1, T2[] a2)
return true;
}

bool _xopEquals(in void* ptr, in void* ptr);

void __ctfeWriteln(T...)(auto ref T) {}

23 changes: 20 additions & 3 deletions src/object_.d
Expand Up @@ -941,12 +941,12 @@ class TypeInfo_Struct : TypeInfo

override equals_t equals(in void* p1, in void* p2)
{
if (p1 == p2)
return true;
else if (!p1 || !p2)
if (!p1 || !p2)
return false;
else if (xopEquals)
return (*xopEquals)(p1, p2);
else if (p1 == p2)
return true;
else
// BUG: relies on the GC not moving objects
return memcmp(p1, p2, init.length) == 0;
Expand Down Expand Up @@ -1024,6 +1024,19 @@ class TypeInfo_Struct : TypeInfo
}
}

unittest
{
struct S
{
const bool opEquals(ref const S rhs)
{
return false;
}
}
S s;
assert(!typeid(S).equals(&s, &s));
}

class TypeInfo_Tuple : TypeInfo
{
TypeInfo[] elements;
Expand Down Expand Up @@ -2781,3 +2794,7 @@ bool _ArrayEq(T1, T2)(T1[] a1, T2[] a2)
}


bool _xopEquals(in void*, in void*)
{
throw new Error("TypeInfo.equals is not implemented");
}
2 changes: 1 addition & 1 deletion win32.mak
Expand Up @@ -799,7 +799,7 @@ $(DRUNTIME): $(OBJS) $(SRCS) win32.mak
$(DMD) -lib -of$(DRUNTIME) -Xfdruntime.json $(DFLAGS) $(SRCS) $(OBJS)

unittest : $(SRCS) $(DRUNTIME) src\unittest.d
$(DMD) $(UDFLAGS) -L/co -unittest src\unittest.d $(SRCS) $(DRUNTIME) -debuglib=$(DRUNTIME_BASE) -defaultlib=$(DRUNTIME_BASE)
$(DMD) $(UDFLAGS) -L/co -unittest src\unittest.d $(SRCS) $(DRUNTIME) -debuglib=$(DRUNTIME) -defaultlib=$(DRUNTIME)

zip: druntime.zip

Expand Down

0 comments on commit 2c06a00

Please sign in to comment.