mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00
By reverting #10718 - it seems superfluous nowadays?
This commit is contained in:
parent
dbe0ddbde6
commit
ed17b3e95d
4 changed files with 96 additions and 8 deletions
|
@ -1247,6 +1247,9 @@ private Expression resolveUFCS(Scope* sc, CallExp ce)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (arrayExpressionSemantic(ce.arguments.peekSlice(), sc))
|
||||||
|
return ErrorExp.get();
|
||||||
|
|
||||||
if (Expression ey = die.dotIdSemanticProp(sc, 1))
|
if (Expression ey = die.dotIdSemanticProp(sc, 1))
|
||||||
{
|
{
|
||||||
if (ey.op == EXP.error)
|
if (ey.op == EXP.error)
|
||||||
|
@ -1254,19 +1257,11 @@ private Expression resolveUFCS(Scope* sc, CallExp ce)
|
||||||
ce.e1 = ey;
|
ce.e1 = ey;
|
||||||
if (isDotOpDispatch(ey))
|
if (isDotOpDispatch(ey))
|
||||||
{
|
{
|
||||||
// even opDispatch and UFCS must have valid arguments,
|
|
||||||
// so now that we've seen indication of a problem,
|
|
||||||
// check them for issues.
|
|
||||||
Expressions* originalArguments = Expression.arraySyntaxCopy(ce.arguments);
|
|
||||||
|
|
||||||
const errors = global.startGagging();
|
const errors = global.startGagging();
|
||||||
e = ce.expressionSemantic(sc);
|
e = ce.expressionSemantic(sc);
|
||||||
if (!global.endGagging(errors))
|
if (!global.endGagging(errors))
|
||||||
return e;
|
return e;
|
||||||
|
|
||||||
if (arrayExpressionSemantic(originalArguments.peekSlice(), sc))
|
|
||||||
return ErrorExp.get();
|
|
||||||
|
|
||||||
/* fall down to UFCS */
|
/* fall down to UFCS */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
77
compiler/test/compilable/imports/test21098_phobos.d
Normal file
77
compiler/test/compilable/imports/test21098_phobos.d
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
struct Nullable(T)
|
||||||
|
{
|
||||||
|
static struct DontCallDestructorT
|
||||||
|
{
|
||||||
|
T payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
DontCallDestructorT _value;
|
||||||
|
|
||||||
|
string toString() const
|
||||||
|
{
|
||||||
|
Appender!string app;
|
||||||
|
formatValueImpl(app, _value);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct Appender(A)
|
||||||
|
{
|
||||||
|
InPlaceAppender!A impl;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct InPlaceAppender(T)
|
||||||
|
{
|
||||||
|
static void toStringImpl(const T[] data)
|
||||||
|
{
|
||||||
|
string app;
|
||||||
|
formatValue(app, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void formatValueImpl(Writer, T)(Writer, const(T)) {}
|
||||||
|
|
||||||
|
void formatValueImpl(Writer, T)(Writer w, T obj)
|
||||||
|
if (is(T == U[], U))
|
||||||
|
{
|
||||||
|
formatValue(w, obj[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum HasToStringResult
|
||||||
|
{
|
||||||
|
none,
|
||||||
|
bla
|
||||||
|
}
|
||||||
|
|
||||||
|
template hasToString(T)
|
||||||
|
{
|
||||||
|
static if (is(typeof(
|
||||||
|
(T val) {
|
||||||
|
val.toString(s);
|
||||||
|
})))
|
||||||
|
enum hasToString = HasToStringResult.bla;
|
||||||
|
else
|
||||||
|
enum hasToString = HasToStringResult.none;
|
||||||
|
}
|
||||||
|
|
||||||
|
void formatValueImpl(Writer, T)(ref Writer w, T val)
|
||||||
|
if (is(T == struct) || is(T == union))
|
||||||
|
{
|
||||||
|
static if (hasToString!T)
|
||||||
|
int dummy;
|
||||||
|
formatElement(w, val.tupleof);
|
||||||
|
}
|
||||||
|
|
||||||
|
void formatElement(Writer, T)(Writer w, T val)
|
||||||
|
{
|
||||||
|
formatValueImpl(w, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void formatValue(Writer, T)(Writer w, T val)
|
||||||
|
{
|
||||||
|
formatValueImpl(w, val);
|
||||||
|
}
|
12
compiler/test/compilable/imports/test21098b.d
Normal file
12
compiler/test/compilable/imports/test21098b.d
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import imports.test21098_phobos : Appender, Nullable;
|
||||||
|
|
||||||
|
struct Type {
|
||||||
|
Nullable!(Type[]) templateArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
Type[] parseDeclarations() {
|
||||||
|
Appender!(Type[]) members;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ast = parseDeclarations();
|
4
compiler/test/compilable/test21098.d
Normal file
4
compiler/test/compilable/test21098.d
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
// https://github.com/dlang/dmd/issues/21098
|
||||||
|
|
||||||
|
// EXTRA_FILES: imports/test21098b.d imports/test21098_phobos.d
|
||||||
|
import imports.test21098b;
|
Loading…
Add table
Add a link
Reference in a new issue