diff --git a/compiler/src/dmd/typesem.d b/compiler/src/dmd/typesem.d index 49f487f91ee6..3e6b59b97e8a 100644 --- a/compiler/src/dmd/typesem.d +++ b/compiler/src/dmd/typesem.d @@ -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)); diff --git a/compiler/test/fail_compilation/ufcs_spell.d b/compiler/test/fail_compilation/ufcs_spell.d new file mode 100644 index 000000000000..e22ade5025d3 --- /dev/null +++ b/compiler/test/fail_compilation/ufcs_spell.d @@ -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); +}