Thread overview
[Issue 11718] New: regression(git head): failed semantic analysis
Dec 10, 2013
Timothee Cour
Dec 11, 2013
Nils
[Issue 11718] [REG2.065a] Unintended mangled names conflict of nested template structs
Dec 12, 2013
Kenji Hara
Dec 17, 2013
Kenji Hara
Dec 18, 2013
Nils
December 10, 2013
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


--- Comment #0 from Timothee Cour <timothee.cour2@gmail.com> 2013-12-10 11:48:34 PST ---
$dmd_064_2_X -main -unittest -run main.d
#ok

$dmd -main -unittest -run main.d
# Error: struct main.setfields!(A).setfields.Proxy!(true, a, null).Proxy failed
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: -------
December 11, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11718


Nils <nilsbossung@googlemail.com> changed:

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


--- Comment #1 from Nils <nilsbossung@googlemail.com> 2013-12-11 14:53:18 PST ---
(In reply to comment #0)
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: -------
December 12, 2013
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


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2013-12-11 23:56:29 PST ---
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: -------
December 16, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11718



--- Comment #3 from github-bugzilla@puremagic.com 2013-12-16 12:53:33 PST ---
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 Merge pull request #2953 from 9rnsr/fix11718

[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: -------
December 17, 2013
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: -------
December 18, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11718



--- Comment #4 from Nils <nilsbossung@googlemail.com> 2013-12-18 15:38:58 PST ---
(In reply to comment #1)
> 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: -------