better error messages for better C#7006
Conversation
|
Thanks for your pull request, @WalterBright! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
d09f83c to
b9451ce
Compare
src/ddmd/mtype.d
Outdated
| s = sc.search_correct(id); | ||
| if (s) | ||
| error(loc, "undefined identifier `%s`, did you mean %s `%s`?", p, s.kind(), s.toChars()); | ||
| else if ((q = Scope.search_correct_C(id)) !is null) |
There was a problem hiding this comment.
I think you can also use the following to narrow the scope q is visible in:
else if (const(char)* q = Scope.search_correct_C(id))
src/ddmd/expression.d
Outdated
| s = sc.search_correct(ident); | ||
| if (s) | ||
| error("undefined identifier `%s`, did you mean %s `%s`?", ident.toChars(), s.kind(), s.toChars()); | ||
| else if ((p = Scope.search_correct_C(ident)) !is null) |
| * Returns: | ||
| * D identifier string if found, null if not | ||
| */ | ||
| extern (C++) static const(char)* search_correct_C(Identifier ident) |
There was a problem hiding this comment.
Can we try to use D naming conventions? In this case, camel case.
There was a problem hiding this comment.
I used the same convention as the existing search_correct to tie the two together.
|
@WalterBright if you are focusing on |
|
@wilzbach I already reviewed dlang/dlang.org#1796 |
|
LGTM |
61acb68 to
ac17e61
Compare
|
This is conflating betterC (a.k.a. tinyD) with porting C code to D, let's hope that won't bite anyone. |
In converting C code to D, these identifiers crop up constantly, justifying a better error message.