Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 21062 - Confusing error when using a keyword as an identifier for… #14627

Merged
merged 1 commit into from
Nov 8, 2022

Conversation

dkorpel
Copy link
Contributor

@dkorpel dkorpel commented Nov 6, 2022

… a declaration

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @dkorpel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Auto-close Bugzilla Severity Description
21062 normal Confusing error when using a keyword as an identifier for a declaration

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#14627"

@dkorpel dkorpel force-pushed the declarator-identifier-keyword branch from 5b49d3e to d124ecb Compare November 6, 2022 20:20
@dkorpel dkorpel marked this pull request as ready for review November 6, 2022 21:00
Comment on lines -223 to -236
static foreach (link; Links)
{
@("extern("~link~")")
unittest
{
auto t = parseModule("test.d", "first_token extern("~link~")");

scope visitor = new LinkVisitor;
t.module_.accept(visitor);

assert(visitor.l.linnum == 1);
assert(visitor.l.charnum == 13);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know why it's testing the location on a broken AST, the following tests look more sensible (except the 'first_token' part).

Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem related to this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With this PR, when the parser sees a keyword used as an identifier, it skips over it (nextToken()) to prevent further broken error messages. This broken test relied on the fact that after encountering a declaration named extern with type first_token, it would continue with parsing the extern declaration anyways.

@RazvanN7 RazvanN7 merged commit 3735e25 into dlang:master Nov 8, 2022
@dkorpel dkorpel deleted the declarator-identifier-keyword branch November 8, 2022 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

3 participants