gedaiu / fluent-asserts

DLang fluent assertions done right
http://fluentasserts.szabobogdan.com/
MIT License
43 stars 6 forks source link

Comparing const array of classes gives compile error #84

Closed Zevenberge closed 6 years ago

Zevenberge commented 6 years ago

Referencing fluent-asserts 0.12.2:

import fluent.asserts;

class A{}

unittest
{
    A a = new A();
    const(A)[] arr = [a];
    arr.should.equal([a]); 
}   

fails with compiler error

/usr/include/dmd/druntime/import/object.d(4235,5): Error: static assert:  "Cannot implicitly convert type A to immutable in idup."
../../.dub/packages/fluent-asserts-0.12.2/fluent-asserts/source/fluentasserts/core/array.d(20,35):        instantiated from here: idup!(A)
../../.dub/packages/fluent-asserts-0.12.2/fluent-asserts/source/fluentasserts/core/array.d(186,34):        instantiated from here: toValueList!(const(A), A[])
source/test.d(12,21):        instantiated from here: equal!(A[])
/usr/bin/dmd failed with exit code 1.

If I replace A with a struct (and don't new it), the assert works. This test compiled with fluent-asserts 0.5.0 (and a full-fledged version passed in my project). If required, I can do some more advanced digging to find the exact version in which this regression was introduced.

gedaiu commented 6 years ago

@Zevenberge thre is no need to do further digging... I will try to fix this during the weekend, but I will not promise :)

gedaiu commented 6 years ago

It should be fixed now. There is a new release, you should be able to use it. :)

Zevenberge commented 6 years ago

Awesome, thanks :)