@@ -4462,6 +4462,10 @@ void resolve(Type mt, const ref Loc loc, Scope* sc, out Expression pe, out Type
44624462 */
44634463Expression dotExp (Type mt, Scope* sc, Expression e, Identifier ident, DotExpFlag flag)
44644464{
4465+ enum LOGDOTEXP = false ;
4466+ if (LOGDOTEXP )
4467+ printf(" dotExp()\n " );
4468+
44654469 Expression visitType (Type mt)
44664470 {
44674471 VarDeclaration v = null ;
@@ -5082,8 +5086,41 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, DotExpFlag
50825086 return noMember (mt, sc, e, ident, flag);
50835087 }
50845088 // check before alias resolution; the alias itself might be deprecated!
5085- if (s.isAliasDeclaration)
5089+ if (auto ad = s.isAliasDeclaration)
5090+ {
50865091 s.checkDeprecated(e.loc, sc);
5092+
5093+ // Fix for https://github.com/dlang/dmd/issues/20610
5094+ if (ad.originalType)
5095+ {
5096+ if (auto tid = ad.originalType.isTypeIdentifier())
5097+ {
5098+ if (tid.idents.length)
5099+ {
5100+ static if (0 )
5101+ {
5102+ printf(" TypeStruct::dotExp(e = '%s', ident = '%s')\n " , e.toChars(), ident.toChars());
5103+ printf(" AliasDeclaration: %s\n " , ad.toChars());
5104+ if (ad.aliassym)
5105+ printf(" aliassym: %s\n " , ad.aliassym.toChars());
5106+ printf(" tid type: %s\n " , toChars(tid));
5107+ }
5108+ /* Rewrite e.s as e.(tid.ident).(tid.idents)
5109+ */
5110+ Expression die = new DotIdExp(e.loc, e, tid.ident);
5111+ foreach (id; tid.idents) // maybe use typeToExpressionHelper()
5112+ die = new DotIdExp(e.loc, die, cast (Identifier)id);
5113+ /* Ambiguous syntax, only way to disambiguate it to try it
5114+ */
5115+ die = dmd.expressionsem.trySemantic(die, sc);
5116+ if (die && die.isDotVarExp()) // shrink wrap around DotVarExp()
5117+ {
5118+ return die;
5119+ }
5120+ }
5121+ }
5122+ }
5123+ }
50875124 s = s.toAlias();
50885125
50895126 if (auto em = s.isEnumMember())
@@ -6074,7 +6111,7 @@ Dsymbol toDsymbol(Type type, Scope* sc)
60746111
60756112 Dsymbol visitIdentifier (TypeIdentifier type)
60766113 {
6077- // printf("TypeIdentifier::toDsymbol('%s')\n", toChars());
6114+ // printf("TypeIdentifier::toDsymbol('%s')\n", toChars(type ));
60786115 if (! sc)
60796116 return null ;
60806117
@@ -6086,7 +6123,6 @@ Dsymbol toDsymbol(Type type, Scope* sc)
60866123 s = t.toDsymbol(sc);
60876124 if (e)
60886125 s = getDsymbol(e);
6089-
60906126 return s;
60916127 }
60926128
0 commit comments