Skip to content

Commit

Permalink
Fix Bugzilla 9997 - Missed misspell suggestions for UFCS
Browse files Browse the repository at this point in the history
  • Loading branch information
ntrel committed Jul 8, 2024
1 parent 67996ab commit 9736659
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
9 changes: 8 additions & 1 deletion compiler/src/dmd/typesem.d
Original file line number Diff line number Diff line change
Expand Up @@ -3209,7 +3209,14 @@ Expression getProperty(Type t, Scope* scope_, const ref Loc loc, Identifier iden
else
{
if (src)
error(loc, "no property `%s` for `%s` of type `%s`", ident.toChars(), src.toChars(), mt.toPrettyChars(true));
{
error(loc, "no property `%s` for `%s` of type `%s`",
ident.toChars(), src.toChars(), mt.toPrettyChars(true));
auto s2 = scope_.search_correct(ident);
if (s2 && s2.isFuncDeclaration)
errorSupplemental(loc, "did you mean %s `%s`?",
s2.kind(), s2.toChars());
}
else
error(loc, "no property `%s` for type `%s`", ident.toChars(), mt.toPrettyChars(true));

Expand Down
16 changes: 16 additions & 0 deletions compiler/test/fail_compilation/ufcs_spell.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
TEST_OUTPUT:
---
fail_compilation/ufcs_spell.d(14): Error: no property `splitlines` for `s` of type `string`
fail_compilation/ufcs_spell.d(14): did you mean function `splitLines`?
fail_compilation/ufcs_spell.d(15): Error: undefined identifier `splitlines`, did you mean function `splitLines`?
---
*/

string splitLines(string);

void main() {
auto s = "red blue";
auto r1 = s.splitlines;
auto r2 = splitlines(s);
}

0 comments on commit 9736659

Please sign in to comment.