From ba6bba6dcea917f441afc0012b1c1b4e5abcf06d Mon Sep 17 00:00:00 2001 From: abul Date: Sun, 13 Apr 2025 23:57:19 +0530 Subject: [PATCH] Fixed --- compiler/src/dmd/typesem.d | 2 +- compiler/test/fail_compilation/fix21165.d | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 compiler/test/fail_compilation/fix21165.d 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() {}