[Issue 12606] Mismatch of known array length during dynamic => static array assignment should emit better diagnostics
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Apr 21 19:09:38 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12606
--- Comment #6 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to Andrej Mitrovic from comment #2)
> For example, in 'implicitConvTo' in the visitor functions 'result' is simply
> initialized to MATCHnomatch if the dimensions of the two slices don't match.
> But this isn't propagate back to the caller side.
If e->implicitConvTo(t) returns MATCHnomatch, e->implicitCastTo(sc, t) should
cause error which represents why e does not match to t.
So, the following compiler code form would be sufficient.
e = e->implicitCastTo(sc, t);
or:
if (e->implicitConvTo(t))
{
e = e->implicitCastTo(sc, t);
assert(e->op != TOKerror); // always succeeds
}
else
{
// extra handling for the unmatch, if e and t have known forms.
if (...)
{
error("more better diagnostic for particular case");
e = new ErrorExp();
}
// error report for generic case
// (if e is already an ErrorExp, no redundant error generated)
e = e->implicitCastTo(sc, t);
}
--
More information about the Digitalmars-d-bugs
mailing list