http://d.puremagic.com/issues/show_bug.cgi?id=8847



--- Comment #5 from Kenji Hara <k.hara...@gmail.com> 2012-11-30 23:46:35 PST ---
This is a serious problem about the name mangling rule for Voldemort Type.

At least there is two rules.
1. Mangled name of a function symbol contains the mangled name of its return
type.
2. A nested declaration's mangled name contains its enclosing mangled name.
---
module test;
pragma(msg, "1f: ", foo.mangleof);
// _D4test3fooFZAi
// --> _D [ 4test 3foo / [ FZ / Ai ] ]   ...#1(Ai == int[])
int[] foo() {
  struct S { int value; }
  pragma(msg, "1i: ", S.mangleof);
  // S4test3fooFZAi1S
  // --> S [ 4test 3foo / [ FZ / Ai ] ] 1S   ...#2
  return null;
}
---

But, Voldemort Types cannot be mangled based on the rules.
Because, a nested struct requires enclosing function's mangling,
but the function requires return type's mangling. It's circular dependency.

In current, that is *accidentally* working.
---
auto bar() {
  struct S { int value; }
  pragma(msg, "2i: ", S.mangleof);
  // S4test3bar1S
  // --> S [ 4test 3bar / [ / ] ] 1S
  // ...incorrect
  return S(1);
}
pragma(msg, "2f: ", bar.mangleof);
// _D4test3barFZS4test3bar1S
// --> _D [ 4test 3bar / [ FZ / S4test3bar1S ] ]
// ...incorrect
---

And, inout type deduction on function call shoots the rule inconsistency.
---
auto baz(inout int = 0) {
  struct S { int value; }
  pragma(msg, "3i: ", S.mangleof);   // S inside bar
  // S4test3baz1S
  // --> S [ 4test 3baz / [ / ] ] 1S   ...(A)
  return inout(S)(1);
}
pragma(msg, "3f: ", baz.mangleof);
// _D4test3bazFNgiZNgS4test3baz1S
// --> _D [ 4test 3baz / [ FNgiZ / Ng S4test3baz1S ] ]

pragma(msg, "3o: ", typeof(baz(0)).mangleof);   // S outside bar
// S4test3bazFNgiZNgS4test3baz1S1S
// --> S [ 4test 3baz / [ FNgiZNg / S4test3baz1S ] ] 1S   ...(B)
---

Compare:
A. --> S [ 4test 3baz / [         /              ] ] 1S
B. --> S [ 4test 3baz / [ FNgiZNg / S4test3baz1S ] ] 1S

Mismatching between A and B is the root cause of this issue.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to