Fix issue 21284: Report "no property" error at identifier location instead of dot#22740
Fix issue 21284: Report "no property" error at identifier location instead of dot#22740Jay-Lokhande wants to merge 2 commits intodlang:masterfrom
Conversation
…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"
|
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 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 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.
|
| } | ||
|
|
||
| static DotIdExp create(Loc loc, Expression e, Identifier ident) @safe | ||
| static DotIdExp create(Loc loc, Expression e, Identifier ident, Loc identLoc = Loc.initial) @safe |
There was a problem hiding this comment.
need update this in the header too
compiler/src/dmd/frontend.h
Outdated
| Loc identLoc; // location of the identifier (for accurate error reporting) | ||
| static DotIdExp* create(Loc loc, Expression* e, Identifier* ident); |
There was a problem hiding this comment.
and in frontend.h here too
There was a problem hiding this comment.
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.
Summary
Fixes #21284: the "no property
Xfor typeY" error was reported at the location of the.instead of the invalid identifier.Before
After
The error is now reported on the line of the identifier: