2011/9/5 Don Clugston <[email protected]>:
> I've never been able to get that to work. Although you can get those
> two to work, it fails in other cases. Eg, as in the code below.
> Have you been able to do this successfully?
>
[snip]
>   assert(s==s2); // fails, ambiguous
[snip]

It is a bug part of issue 5889, and I know how to fix it.
see https://github.com/D-Programming-Language/dmd/pull/41/files

TypeStruct::defaultInit() returns the expression of S.init, but it is
lvalue. so the ref-nonref resolution was failed against struct type in
FuncDeclaration::leastAsSpecialized.

The changes of dmd/pull/41:
- Use TypeStruct::defaultInitLiteal() (returns S()) instead of
TypeStruct::defaultInit() in FuncDeclaraton::leastAsSpecialized()
- Change S() from lvalue to rvalue
  <- Remove StructLiteralExp::isLvalue
  <- Wrap CallExp (S __ctmp = 0; __ctmp).this(ctorargs...) into
StructContructExp, and make it rvalue

----

I think string literal shoud be rvalue, like array literal (e.g. [e0,
e1, ..., eN]).
And also struct literal should be rvalue.
The passable to a ref parameter for the two kind of literals is
definitely bug to me.

Kenji Hara
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos

Reply via email to