D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 14109 - [REG2.066.1] Property-like function call does not work on template value parameter
Summary: [REG2.066.1] Property-like function call does not work on template value para...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords: pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2015-02-02 02:11 UTC by Timothee Cour
Modified: 2015-02-03 20:29 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Timothee Cour 2015-02-02 02:11:37 UTC
dmd -unittest -c -o- main.d

2.066: works
git head(v2.067-devel-e542e14): 
Error: no property 'z' for type 'Proxy!(true, a, null)'

----
auto setFields_aux(bool isRef,alias foo,string s,T...)(T args){
  import std.array:split;
  import std.conv:to;
  enum namesCall=split(s,",");
  static assert(namesCall.length==T.length);
  static if(isRef){
    enum foo2_name="foo";
  }
  else{
    auto foo2=foo;
    enum foo2_name="foo2";
  }
  
  string getString()
  {
    string ret;    
    foreach(i,vali ; namesCall){
      ret~=foo2_name~`.`~vali~`=`~`args[`~i.to!string~`];`;
    }
    ret~=`return `~foo2_name~`;`;
    return ret;
  }
  mixin(getString());
}

private struct Proxy (bool isRef,alias func, string parameters, Args ...)
{
  private static string addParameter (string parameters, string newParameter) ()
  {
    return parameters is null ? newParameter : parameters ~ "," ~ newParameter;
  }

  Args args;
  this(int dummy,Args args){
    static if(Args.length)
      this.args=args;
  }

  auto opDispatch (string name, T) (T value)
  {
    return Proxy!(isRef,func, addParameter!(parameters, name), Args, T)(0,args, value);
  }

  auto opCall()()
  {
    return setFields_aux!(isRef,func, parameters)(args);
  }
}

auto ref setfieldsRef(T)(ref T a){
  return Proxy!(true,a, null)(0);
}

auto setfields(T)(T a){
  return Proxy!(true,a, null)(0);
}
auto setfields(T)(){
  T a;
  return Proxy!(true,a, null)(0);  
}

unittest{ 
  struct A{
    string z;
  }
  auto a0=A("a");
  assert(A.init.setfields.z("a")() == a0);
}
----
Comment 1 Kenji Hara 2015-02-03 09:49:57 UTC
Reduced test case:

string addParameter()() { return ""; }
struct Proxy(string parameters) {}
alias P = Proxy!(addParameter!());
// works with 2.066, but doesn't work with 2.066.1

Introduced in: https://github.com/D-Programming-Language/dmd/pull/3897
Comment 3 github-bugzilla 2015-02-03 20:29:28 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/bcd157daa58bc84edddc2d5eeeaae7e8e001eca7
fix Issue 14109 - Property-like function call does not work on template value parameter

https://github.com/D-Programming-Language/dmd/commit/e8dba387fcaa55f176891750c83dba6513ccba69
Merge pull request #4375 from 9rnsr/fix14109

[REG2.066.1] Issue 14109 - Property-like function call does not work on template value parameter