Skip to content

Implement $ type inference#22715

Open
IDONTUSEGH wants to merge 10 commits intodlang:masterfrom
IDONTUSEGH:dollar-infer
Open

Implement $ type inference#22715
IDONTUSEGH wants to merge 10 commits intodlang:masterfrom
IDONTUSEGH:dollar-infer

Conversation

@IDONTUSEGH
Copy link
Copy Markdown
Contributor

Following recent forum discussions regarding . type inference that sparked my interest, it was noted that the dot syntax conflicts with module scope resolution.

So after some digging, I found that using $ had been suggested as a viable alternative in past discussions.

I couldn't find the original DIP (if there was any), so I decided to explore the feasibility of a $ based implementation.

And it turns out the logic is suprisingly straightforward, and this PR demonstrates how it could be integrated.

To keep the scope manageable and code easy to read, the compiler will an error if the context is too ambiguous to resolve.

This was a fun week end project, I'm pretty excited about this feature.

https://forum.dlang.org/post/yegslrvshbtlqcchcufi@forum.dlang.org

@dlang-bot
Copy link
Copy Markdown
Contributor

Thanks for your pull request and interest in making D better, @IDONTUSEGH! 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 "master + dmd#22715"

@IDONTUSEGH
Copy link
Copy Markdown
Contributor Author

I forgot to run Phobos tests locally, I'll investigate the failures.

@UplinkCoder
Copy link
Copy Markdown
Member

I tried to implement this a couple years ago.
it failed to be useable generically.

@IDONTUSEGH
Copy link
Copy Markdown
Contributor Author

I tried to implement this a couple years ago. it failed to be useable generically.

I think keeping the scope small on clear contextual targets (erroring on ambiguity as early as possible) avoids the issues of trying to make it too generic.

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.

3 participants