Skip to content

Fix issue 21284: Report "no property" error at identifier location instead of dot#22740

Open
Jay-Lokhande wants to merge 2 commits intodlang:masterfrom
Jay-Lokhande:fix-21284-no-property-error-location
Open

Fix issue 21284: Report "no property" error at identifier location instead of dot#22740
Jay-Lokhande wants to merge 2 commits intodlang:masterfrom
Jay-Lokhande:fix-21284-no-property-error-location

Conversation

@Jay-Lokhande
Copy link
Copy Markdown

Summary

Fixes #21284: the "no property X for type Y" error was reported at the location of the . instead of the invalid identifier.

Before

auto x =
    E
    .
    three;
test.d(6): Error: no property `three` for type `E`

After
The error is now reported on the line of the identifier:

test.d(8): Error: no property `three` for type `E`

…ier location

- Add identLoc to DotIdExp (parser sets it from token.loc)
- Thread identLoc through getProperty/dotExp and use for error location
- Add test diag21284.d"
@Jay-Lokhande Jay-Lokhande requested a review from ibuclaw as a code owner March 15, 2026 09:25
@dlang-bot
Copy link
Copy Markdown
Contributor

Thanks for your pull request and interest in making D better, @Jay-Lokhande! 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

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.

⚠️⚠️⚠️ Warnings ⚠️⚠️⚠️

  • In preparation for migrating from Bugzilla to GitHub Issues, the issue reference syntax has changed. Please add the word "Bugzilla" to issue references. For example, Fix Bugzilla Issue 12345 or Fix Bugzilla 12345.(Reminder: the edit needs to be done in the Git commit message, not the GitHub pull request.)

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#22740"

}

static DotIdExp create(Loc loc, Expression e, Identifier ident) @safe
static DotIdExp create(Loc loc, Expression e, Identifier ident, Loc identLoc = Loc.initial) @safe
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

need update this in the header too

Comment on lines 2797 to 2798
Loc identLoc; // location of the identifier (for accurate error reporting)
static DotIdExp* create(Loc loc, Expression* e, Identifier* ident);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and in frontend.h here too

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks! updated the C++ headers as well added identLoc parameter (with default Loc()) to DotIdExp::create in both compiler/src/dmd/expression.h and compiler/src/dmd/frontend.h.

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.

Wrong location for "no property ... on type ..." error

3 participants