By reverting #10718 - it seems superfluous nowadays?
This commit is contained in:
Martin Kinkelin 2025-04-02 01:42:03 +02:00 committed by GitHub
parent dbe0ddbde6
commit ed17b3e95d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 96 additions and 8 deletions

View file

@ -1247,6 +1247,9 @@ private Expression resolveUFCS(Scope* sc, CallExp ce)
}
else
{
if (arrayExpressionSemantic(ce.arguments.peekSlice(), sc))
return ErrorExp.get();
if (Expression ey = die.dotIdSemanticProp(sc, 1))
{
if (ey.op == EXP.error)
@ -1254,19 +1257,11 @@ private Expression resolveUFCS(Scope* sc, CallExp ce)
ce.e1 = 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();
e = ce.expressionSemantic(sc);
if (!global.endGagging(errors))
return e;
if (arrayExpressionSemantic(originalArguments.peekSlice(), sc))
return ErrorExp.get();
/* fall down to UFCS */
}
else

View 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);
}

View 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();

View file

@ -0,0 +1,4 @@
// https://github.com/dlang/dmd/issues/21098
// EXTRA_FILES: imports/test21098b.d imports/test21098_phobos.d
import imports.test21098b;