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 23355: invalid template parameter loses error location in some cases (T[UndefinedIdentifier] has no error loc) #14465

Merged
merged 1 commit into from Sep 22, 2022

Conversation

WebFreak001
Copy link
Member

@WebFreak001 WebFreak001 commented Sep 21, 2022

Types (e.g. TypeAArray) don't have a location attached to them, so instead of trying to use that we instead use the error location from the general template parameters.

@maxhaton

The error message came from here:

error(loc, "undefined identifier `%s`", p);

which was called from the here changed file.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WebFreak001!

Bugzilla references

Auto-close Bugzilla Severity Description
23355 minor invalid template parameter loses error location in some cases

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

Types (e.g. TypeAArray) don't have a location attached to them, so
instead of trying to use that we instead
use the error location from the general template parameters.

Co-authored-by: mhh <maxhaton@gmail.com>
// use the first location of template parameters as we
// don't have any other location set anywhere.
// not completely accurate, but better than nothing.
if (inferStart < parameters.dim)
Copy link
Member

Choose a reason for hiding this comment

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

can this ever be false?

Copy link
Member Author

Choose a reason for hiding this comment

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

inferStart has a few assignments in a few places in the code where it's assigned to parameters.dim, would prefer to keep this check because I have not analyzed all the different sources where this function may be called from.

Copy link
Member

Choose a reason for hiding this comment

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

It might be right to have it be an assertion.

Those are set to make [inferStart..end] == [] I think.

Issue is whether there's going to be an assertion failure because it. These functions are the back-rooms of dmd

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 think this whole file really needs a refactoring, there is a lot of code duplication happening here. Would prefer not to add any breaking changes, such as an assert, here.

Copy link
Member

Choose a reason for hiding this comment

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

That need for refactoring is why we don't have named args

@RazvanN7 RazvanN7 merged commit 284fcc0 into dlang:master Sep 22, 2022
maxhaton added a commit to maxhaton/dmd that referenced this pull request Sep 24, 2022
Types (e.g. TypeAArray) don't have a location attached to them, so
instead of trying to use that we instead
use the error location from the general template parameters.

Co-authored-by: mhh <maxhaton@gmail.com>

Co-authored-by: mhh <maxhaton@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants