diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2025-03-22 10:49:06 +0100 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2025-03-22 10:55:13 +0100 |
commit | 33a428f966d6583d47524a5274f519d4490d0e01 (patch) | |
tree | c3499987fbe20bc102f27cb9c3ddffb240ced4ec /gcc/d | |
parent | 1f42269ee49240ac68a877c29a26306fcc246c2d (diff) | |
download | gcc-33a428f966d6583d47524a5274f519d4490d0e01.zip gcc-33a428f966d6583d47524a5274f519d4490d0e01.tar.gz gcc-33a428f966d6583d47524a5274f519d4490d0e01.tar.bz2 |
d: Improve UFCS/property error message
Improves on the speller suggestions for UFCS by using the location of
the suggested symbol, and considering that local functions aren't
eligible for UFCS instead of making a nonsensical suggestion, such as
"no property foo, did you mean foo?".
gcc/d/ChangeLog:
* dmd/MERGE: Merge upstream dmd 9d2f034398.
Reviewed-on: https://github.com/dlang/dmd/pull/21046
Diffstat (limited to 'gcc/d')
-rw-r--r-- | gcc/d/dmd/MERGE | 2 | ||||
-rw-r--r-- | gcc/d/dmd/typesem.d | 14 |
2 files changed, 12 insertions, 4 deletions
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 9982d0d..0b554f1 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -94950cae582d89f5ba2720786522f669f620f9d1 +9d2f034398c33be1a28d8c60721014a6ab34d652 The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/gcc/d/dmd/typesem.d b/gcc/d/dmd/typesem.d index 65bad38..c5a3b83 100644 --- a/gcc/d/dmd/typesem.d +++ b/gcc/d/dmd/typesem.d @@ -3444,8 +3444,16 @@ Expression getProperty(Type t, Scope* scope_, Loc loc, Identifier ident, int fla auto s2 = scope_.search_correct(ident); // UFCS if (s2 && s2.isFuncDeclaration) - errorSupplemental(loc, "did you mean %s `%s`?", - s2.kind(), s2.toChars()); + { + if (s2.ident == ident) + { + errorSupplemental(s2.loc, "cannot call %s `%s` with UFCS because it is not declared at module scope", + s2.kind(), s2.toChars()); + } + else + errorSupplemental(s2.loc, "did you mean %s `%s`?", + s2.kind(), s2.toChars()); + } else if (src.type.ty == Tpointer) { // structPtr.field @@ -3454,7 +3462,7 @@ Expression getProperty(Type t, Scope* scope_, Loc loc, Identifier ident, int fla { if (auto s3 = as.search_correct(ident)) { - errorSupplemental(loc, "did you mean %s `%s`?", + errorSupplemental(s3.loc, "did you mean %s `%s`?", s3.kind(), s3.toChars()); } } |