Skip to content

better error messages for better C#7006

Merged
andralex merged 1 commit intodlang:masterfrom
WalterBright:cwords
Aug 5, 2017
Merged

better error messages for better C#7006
andralex merged 1 commit intodlang:masterfrom
WalterBright:cwords

Conversation

@WalterBright
Copy link
Member

In converting C code to D, these identifiers crop up constantly, justifying a better error message.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

@WalterBright WalterBright force-pushed the cwords branch 2 times, most recently from d09f83c to b9451ce Compare July 18, 2017 08:17
Copy link
Member

@PetarKirov PetarKirov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would prevent inling.

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

* Returns:
* D identifier string if found, null if not
*/
extern (C++) static const(char)* search_correct_C(Identifier ident)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we try to use D naming conventions? In this case, camel case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the same convention as the existing search_correct to tie the two together.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(

@wilzbach
Copy link
Contributor

@WalterBright if you are focusing on betterC, it would be great if we could document it: dlang/dlang.org#1796

@WalterBright
Copy link
Member Author

@wilzbach I already reviewed dlang/dlang.org#1796

@atilaneves
Copy link
Contributor

LGTM

@WalterBright WalterBright force-pushed the cwords branch 2 times, most recently from 61acb68 to ac17e61 Compare August 5, 2017 01:26
@andralex andralex merged commit 1f8f81b into dlang:master Aug 5, 2017
@WalterBright WalterBright deleted the cwords branch August 6, 2017 01:33
@MartinNowak
Copy link
Member

This is conflating betterC (a.k.a. tinyD) with porting C code to D, let's hope that won't bite anyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants