Report correct location for undefined identifiers in function return types (#21223)

This commit is contained in:
Abul Hossain Khan 2025-04-14 13:38:52 +05:30 committed by GitHub
parent 5fcca3e152
commit d657667ff8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 3 deletions

View file

@ -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()))

View file

@ -4,7 +4,7 @@ TEST_OUTPUT:
fail_compilation/b23686.d(107): Error: undefined identifier `eFN1`, did you mean template `eFN0()()`?
fail_compilation/b23686.d(107): Error: `mixin(_error_)` does not give a valid type
fail_compilation/b23686.d(115): while looking for match for `eload!(int, 1)`
fail_compilation/b23686.d(121): Error: undefined identifier `FNwtf`
fail_compilation/b23686.d-mixin-121(121): Error: undefined identifier `FNwtf`
fail_compilation/b23686.d(121): Error: `mixin(_error_)` does not give a valid type
fail_compilation/b23686.d(126): while looking for match for `load!"wtf"`
---

View file

@ -0,0 +1,10 @@
/*
TEST_OUTPUT:
---
fail_compilation/fix21165.d(9): Error: undefined identifier `foo`
---
*/
// Test case from Issue #21165
foo
f() {}

View file

@ -117,7 +117,7 @@ TEST_OUTPUT:
---
fail_compilation/noreturn2.d(130): Error: cannot create instance of interface `I`
fail_compilation/noreturn2.d(133): Error: can only throw class objects derived from `Throwable`, not type `int[]`
fail_compilation/noreturn2.d(138): Error: undefined identifier `UnkownException`
fail_compilation/noreturn2.d(139): Error: undefined identifier `UnkownException`
---
+/