1. Fixes an ICE in the front-end if a struct symbol were to appear twice
in the compilation unit.
2. Fixes a rejects-valid bug in the front-end where `(symbol)' was being
resolved as a `var' expression, instead of `this.var'.
Reviewed-on: https://github.com/dlang/dmd/pull/11436
	     https://github.com/dlang/dmd/pull/11439
gcc/d/ChangeLog:
	PR d/96250
	* dmd/MERGE: Merge upstream dmd 
c2274e56a.
-8508c4e683f065eb3deab76b610f7fecb3258a8e
+c2274e56a3220ea636c6199fd06cd54fcdf6bad9
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
 
         }
     }
 
+    if (type->ty == Tstruct && ((TypeStruct *)type)->sym != this)
+    {
+        // https://issues.dlang.org/show_bug.cgi?id=19024
+        StructDeclaration *sd = ((TypeStruct *)type)->sym;
+        error("already exists at %s. Perhaps in another function with the same name?", sd->loc.toChars());
+    }
+
     if (global.errors != errors)
     {
         // The type is no good.
         deferred->semantic2(sc);
         deferred->semantic3(sc);
     }
-
-    assert(type->ty != Tstruct || ((TypeStruct *)type)->sym == this);
 }
 
 Dsymbol *StructDeclaration::search(const Loc &loc, Identifier *ident, int flags)
 
         exp->type->resolve(exp->loc, sc, &e, &t, &s, true);
         if (e)
         {
+            // `(Type)` is actually `(var)` so if `(var)` is a member requiring `this`
+            // then rewrite as `(this.var)` in case it would be followed by a DotVar
+            // to fix https://issues.dlang.org/show_bug.cgi?id=9490
+            VarExp *ve = e->isVarExp();
+            if (ve && ve->var && exp->parens && !ve->var->isStatic() && !(sc->stc & STCstatic) &&
+                sc->func && sc->func->needThis() && ve->var->toParent2()->isAggregateDeclaration())
+            {
+                // printf("apply fix for issue 9490: add `this.` to `%s`...\n", e->toChars());
+                e = new DotVarExp(exp->loc, new ThisExp(exp->loc), ve->var, false);
+            }
             //printf("e = %s %s\n", Token::toChars(e->op), e->toChars());
             e = semantic(e, sc);
         }
 
                                 return NULL;
                             }
                             e = new TypeExp(loc, t);
+                            e->parens = 1;
                             e = parsePostExp(e);
                         }
                         else
 
--- /dev/null
+// https://issues.dlang.org/show_bug.cgi?id=9490
+class A
+{
+    int[1] arr;
+
+    this()
+    {
+        assert(arr.length);
+        assert((arr).length);
+    }
+}
+
+class C
+{
+    struct Foo { int a; void funcToo(){} }
+    Foo foo;
+
+    auto get(){return foo;}
+
+    void test()
+    {
+        // Error: need 'this' to access member a
+        (foo).a = 1;
+        (foo).funcToo();
+        (get()).a = 2;
+    }
+}
+
+struct S { int i; }
+struct S1 { S s; }
+void f(int) { }
+
+void main()
+{
+    S1 s1;
+    f(s1.s.tupleof); // OK
+    f((s1.s).tupleof); // Error: need 'this' to access member s
+}
+
 
--- /dev/null
+// REQUIRED_ARGS: -o-
+
+void main(string[] args)
+{
+    immutable int a;
+    immutable int b;
+    S!a sa;
+    S!b sb;
+    C!a ca;
+    C!b cb;
+}
+
+struct S(alias a)
+{
+}
+
+class C(alias a)
+{
+}
 
 /* TEST_OUTPUT:
 ---
-fail_compilation/fail17492.d(19): Error: class fail17492.C.testE.I already exists at fail_compilation/fail17492.d(12). Perhaps in another function with the same name?
+fail_compilation/fail17492.d(20): Error: class `fail17492.C.testE.I` already exists at fail17492.d(13). Perhaps in another function with the same name?
+fail_compilation/fail17492.d(37): Error: struct `fail17492.S.testE.I` already exists at fail17492.d(30). Perhaps in another function with the same name?
 ---
 https://issues.dlang.org/show_bug.cgi?id=17492
 */
         }
     }
 }
+
+class S
+{
+    void testE()
+    {
+        struct I
+        {
+        }
+    }
+
+    void testE()
+    {
+        struct I
+        {
+        }
+    }
+}
 
--- /dev/null
+/*
+EXTRA_FILES: imports/ice21060a/package.d imports/ice21060b/package.d imports/ice21060c/package.d imports/ice21060d/package.d
+TEST_OUTPUT:
+---
+fail_compilation/imports/ice21060b/package.d(3): Error: struct `imports.ice21060d.P21060` already exists at fail_compilation/imports/ice21060d/package.d(3). Perhaps in another function with the same name?
+---
+*/
+struct S21060
+{
+    void print()
+    {
+        import imports.ice21060a;
+        import imports.ice21060b;
+    }
+}
 
--- /dev/null
+import imports.ice21060c;
 
--- /dev/null
+module imports.ice21060d;
+
+struct P21060
+{
+}
 
--- /dev/null
+import imports.ice21060d;
 
--- /dev/null
+module imports.ice21060d;
+
+struct P21060
+{
+}
 
--- /dev/null
+// REQUIRED_ARGS: -main
+class A()
+{
+    static struct S { A a; }
+}
+enum e = is(A!());