www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11718] New: regression(git head): failed semantic analysis

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11718

           Summary: regression(git head): failed semantic analysis
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: timothee.cour2 gmail.com



11:48:34 PST ---
$dmd_064_2_X -main -unittest -run main.d
#ok

$dmd -main -unittest -run main.d

semantic analysis

---
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 setfields(T)(T a){
  return Proxy!(true,a, null)(0);
}
auto setfields(T)(){
  T a;
  return Proxy!(true,a, null)(0);  
}

unittest{ 
  struct A{
    int x;
    float y=10;
    string z;
  }

  auto z1=A.init.setfields.z("a").x(3)();
  auto z2=setfields!A.z("a").x(3)();
}
---

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 10 2013
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11718


Nils <nilsbossung googlemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nilsbossung googlemail.com



---

Reduced:
---
cat > test1.d << code
struct Proxy(alias a) {}
auto setfields(int a)
{
    Proxy!a p;
    return p;
}
auto setfields()
{
    int a;
    Proxy!a p;
    return p;
}
code
dmd -c test1.d
---
test1.d(1): Error: struct test1.setfields.Proxy!(a).Proxy failed semantic
analysis
test1.d(10): Error: template instance test1.setfields.Proxy!(a) error
instantiating
---

And another, similar trigger:
---
cat > test2.d << code
mixin template M()
{
    struct S {}
}
mixin M!();
mixin M!();
code
dmd -c test2.d
---
test2.d(3): Error: struct test2.M!().S failed semantic analysis
test2.d(6): Error: mixin test2.M!() error instantiating
---

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 11 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11718


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid
            Summary|regression(git head):       |[REG2.065a] Unintended
                   |failed semantic analysis    |mangled names conflict of
                   |                            |nested template structs



https://github.com/D-Programming-Language/dmd/pull/2953

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 11 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11718




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/71b0fce3a4f2849e82c9ba9972a65a6fee59d42f
fix Issue 11718 - Unintended mangled names conflict of nested template structs

If a symbol has parent, the parent part of the mangled name should also be
unique in each scopes.

Function symbols can have same identifiers in scope, so their parameters part
must be always encoded in their mangled name to distinguish overloads.

When I fixed bug 9271, I had naturally expected that behavior. However sadly
`mangle` function had had a bug.

https://github.com/D-Programming-Language/dmd/commit/95183bfb5265af56d5f03cbfdc8b59d9a7c47789


[REG2.065a] Issue 11718 - Unintended mangled names conflict of nested template
structs

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 16 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11718


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 16 2013
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11718




---

 And another, similar trigger:
 ---
 cat > test2.d << code
 mixin template M()
 {
     struct S {}
 }
 mixin M!();
 mixin M!();
 code
 dmd -c test2.d
 ---
 test2.d(3): Error: struct test2.M!().S failed semantic analysis
 test2.d(6): Error: mixin test2.M!() error instantiating
 ---
Opened a new ticket for this: bug 11767 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 18 2013