[Issue 14109] New: no property 'z' for type 'Proxy!(true, a, null)

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Feb 1 18:11:37 PST 2015


https://issues.dlang.org/show_bug.cgi?id=14109

          Issue ID: 14109
           Summary: no property 'z' for type 'Proxy!(true, a, null)
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: regression
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: timothee.cour2 at gmail.com

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);
}
----

--


More information about the Digitalmars-d-bugs mailing list