D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10526 - opDispatch with IFTI should not disable UFCS
Summary: opDispatch with IFTI should not disable UFCS
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2013-07-02 19:27 UTC by Kenji Hara
Modified: 2013-07-05 11:20 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Kenji Hara 2013-07-02 19:27:17 UTC
From: http://forum.dlang.org/post/cxgefmgjnzgoizrdtcbb@forum.dlang.org

In following code, opDispatch call requires IFTI due to TemplateTupleParameter T deduction. However it unexpectedly disables UFCS.

import std.conv, std.stdio, std.algorithm;

struct S
{
    void opDispatch(string s, T...)(T t)
    if (s.startsWith("foo")) 
    {
        writeln(s);
    }
}

void main()
{
    S s;

    s.foo();
    // --> OK

    auto p = s.to!string();
    // --> Error: s.opDispatch!("to") isn't a template
}
Comment 2 github-bugzilla 2013-07-05 11:20:31 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/10ce85d0d9c661843ad8bd77c23f229bf5732ca1
fix Issue 10526 - opDispatch with IFTI should not disable UFCS

When opDispatch result is a function template that requires IFTI, it would be kept on `DotTemplateInstanceExp` so `ti->needsTypeInference(sc)` returns TRUE in its semantic().

UFCS dispatch should check that the opDispatch result is really valid or not, by instantiating the function template.

https://github.com/D-Programming-Language/dmd/commit/11d22d63ac22eb5980b6370f5f93a2a22e995e29
Merge pull request #2292 from 9rnsr/fix_ufcs

Issue 10526 - opDispatch with IFTI should not disable UFCS