[phobos] [D-Programming-Language/phobos] 601c75: Improve parsing error handling

kenji hara k.hara.pg at gmail.com
Mon Sep 5 02:50:17 PDT 2011


2011/9/5 Don Clugston <dclugston at googlemail.com>:
> 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


More information about the phobos mailing list