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 IFTI with named arguments #15040

Merged
merged 1 commit into from
Mar 7, 2024
Merged

Conversation

dkorpel
Copy link
Contributor

@dkorpel dkorpel commented Mar 25, 2023

deduceFunctionTemplateMatch makes the assumption that the arguments and parameters arrays are parallel, and resolveNamedArguments doesn't handle template tuple parameters yet. Also, default parameters can come before nfargs now, so the logic comparing argi with nfargs has to be rewritten.

@dkorpel dkorpel added the Review:WIP Work In Progress - not ready for review or pulling label Mar 25, 2023
@dlang-bot
Copy link
Contributor

dlang-bot commented Mar 25, 2023

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

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.

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 "stable + dmd#15040"

@dkorpel dkorpel changed the title [WIP] Fix IFTI with named args [WIP] Fix IFTI with named arguments Mar 25, 2023
@dkorpel dkorpel force-pushed the named-arg-ifti branch 2 times, most recently from 3118235 to c4dff12 Compare January 4, 2024 15:23
@dkorpel dkorpel changed the title [WIP] Fix IFTI with named arguments Fix IFTI with named arguments Jan 4, 2024
@dkorpel dkorpel marked this pull request as ready for review February 28, 2024 11:51
@dkorpel
Copy link
Contributor Author

dkorpel commented Feb 28, 2024

I think this is ready to go. There's future improvements for error messages and tuples, but I don't want this PR to grow bigger, and all the recent refactoring commits keep pulling out the rug from under this PR so I'd like to get this in before I have to rebase again :)

@dkorpel dkorpel removed the Review:WIP Work In Progress - not ready for review or pulling label Feb 28, 2024
compiler/src/dmd/dtemplate.d Show resolved Hide resolved
@@ -5723,8 +5754,7 @@ extern (C++) final class TemplateMixin : TemplateInstance

/************************************
* This struct is needed for TemplateInstance to be the key in an associative array.
* Fixing https://issues.dlang.org/show_bug.cgi?id=15812 and
* https://issues.dlang.org/show_bug.cgi?id=15813 would make it unnecessary.
* Fixing https://issues.dlang.org/show_bug.cgi?id=15813 would make it unnecessary.
Copy link
Contributor

Choose a reason for hiding this comment

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

This change, although correct, seems unrelated. I just want to make sure this change is intended and not the left overs of a different branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's intended, I'm updating outdated or confusing comments as I come across them. (Though I won't mix unrelated code changes of course)

/*
TEST_OUTPUT:
---
fail_compilation/named_arguments_ifti_error.d(17): Error: template `f` is not callable using argument types `!()(int, int)`
Copy link
Contributor

Choose a reason for hiding this comment

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

This error message does not seem to accurately explain what the problem is. I would expect something along the lines of: "Missing argument for parameter 'y'".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is that the current template instantiation code gags / discards most error messages, requiring a refactor to make more informative errors. I don't want to add that to this PR, but want to look into improving this next (which is long overdue; template errors are a big source of confusion especially with ref and lambda parameters).


void main()
{
f(x: 3, x: 3);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a typo? Did you mean 'y' for the second 'x' ? Either way, the error for assigning a value to 'x' twice is misleading.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a fail compilation test, it's testing that wrong use of names doesn't succeed in instantiating. I added comments to the test case to clarify.

@ibuclaw
Copy link
Member

ibuclaw commented Mar 4, 2024

Is this worth retargeting for stable/the current 2.108 beta?

@RazvanN7
Copy link
Contributor

RazvanN7 commented Mar 6, 2024

cc @dkorpel

@dkorpel dkorpel changed the base branch from master to stable March 6, 2024 10:47
@dkorpel
Copy link
Contributor Author

dkorpel commented Mar 6, 2024

Yes, this was meant for 2.108, so targeting stable now.

@thewilsonator
Copy link
Contributor

Is this supposed to contain 5 commits, 4 of which look unrelated?

@dkorpel
Copy link
Contributor Author

dkorpel commented Mar 6, 2024

No, I don't know why they are there. Git says it's up to date with stable.

@thewilsonator thewilsonator merged commit 1ca600b into dlang:stable Mar 7, 2024
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

5 participants