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

Supplemental fix for issue 14735 - Prevent self-recursive match #3446

Merged
merged 1 commit into from Jun 29, 2015

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Jun 27, 2015

The slice expression s[] will match to T[n] by using compile-time length deduction.

Required by: dlang/dmd#4779

The slice expression `s[]` will match to T[n] by using compile-time length deduction.
@schuetzm
Copy link
Contributor

The slice expression s[] will match to T[n] by using compile-time length deduction.

Huh? Why's that? typeof(s[]) is T[], why should it match T[n]? Is the length deduction you're talking about documented somewhere?

@9rnsr
Copy link
Contributor Author

9rnsr commented Jun 28, 2015

Sorry it's not well documented in the spec. It's only in the changelog text:
http://dlang.org/changelog#implicitarraycast

Yes, typeof(s[]) is T[]. but s is a static array T[n] so it's whole slice length can be known at compile time.

@schuetzm
Copy link
Contributor

What a surprise! I always assumed that things like this only worked inside one expression (like VRP)...

@schuetzm
Copy link
Contributor

What a surprise! I always assumed that things like this only worked inside one expression (like VRP)...

Ok, I see it does only work inside one expression.

But on further thought, I don't like this, at least not if it requires hacks such as this one. T[] -> T[n] is an implicit conversion, so it should is already a worse match if there is an overload that takes T[] directly. But this apparently didn't help in this case, because it is still preferred to overloads with template constraints. I feel this is too bug-prone...

@WalterBright
Copy link
Member

Regardless of whether this is a misfeature or not, I'm going to pull this because that debate should go elsewhere.

@WalterBright
Copy link
Member

Auto-merge toggled on

WalterBright added a commit that referenced this pull request Jun 29, 2015
Supplemental fix for issue 14735 - Prevent self-recursive match
@WalterBright WalterBright merged commit f6ce569 into dlang:master Jun 29, 2015
@9rnsr 9rnsr deleted the fix14735 branch June 29, 2015 23:36
9rnsr pushed a commit to 9rnsr/phobos that referenced this pull request Jun 30, 2015
Supplemental fix for issue 14735 - Prevent self-recursive match
9rnsr pushed a commit to 9rnsr/phobos that referenced this pull request Jun 30, 2015
Supplemental fix for issue 14735 - Prevent self-recursive match
@MartinNowak MartinNowak added this to the 2.068 milestone Jul 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants