diff --git a/compiler/src/dmd/typesem.d b/compiler/src/dmd/typesem.d index 59f22fa77871..f0cf67380294 100644 --- a/compiler/src/dmd/typesem.d +++ b/compiler/src/dmd/typesem.d @@ -181,7 +181,7 @@ private void resolveHelper(TypeQualified mt, Loc loc, Scope* sc, Dsymbol s, Dsym (id == Id._super && sc.getClassScope())) error(loc, "undefined identifier `%s`, did you mean `typeof(%s)`?", p, p); else - error(loc, "undefined identifier `%s`", p); + error(mt.loc, "undefined identifier `%s`", p); } else { if (const n = cIncludeHint(id.toString())) diff --git a/compiler/test/fail_compilation/fix21165.d b/compiler/test/fail_compilation/fix21165.d new file mode 100644 index 000000000000..ad8f586d9eb3 --- /dev/null +++ b/compiler/test/fail_compilation/fix21165.d @@ -0,0 +1,10 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/fix21165.d(9): Error: undefined identifier `foo` +--- +*/ + +// Test case from Issue #21165 +foo +f() {}