Comment #0 by andrej.mitrovich — 2012-10-03T16:00:33Z
import std.stdio;
void foo(const int x) { }
void bar(const scope int x) { }
void doo(in int x) { }
void main()
{
writeln(foo.mangleof);
writeln(bar.mangleof);
writeln(doo.mangleof);
}
_D4test3fooFxiZv
_D4test3barFMxiZv
_D4test3dooFxiZv
'doo' should have the same mangling as 'bar', but it has mangling as 'foo'. Fixing this will fix Issue 8695.
Comment #1 by k.hara.pg — 2012-10-04T07:36:17Z
This is difficult issue. Because, with current dmd, scope parameter does affects only for delegate types. For other types, it has no meaning.
Furthermore, the equality 'in' == 'const scope' is almost a lie.
In semantic phase, 'in' storage class is directly translated to 'const' storage class, then affects to the parameter type. There is no appearance of 'scope'.
void foo(const scope void delegate() dg){}
void bar( in void delegate() dg){}
pragma(msg, typeof(foo)); // void(scope const(void delegate()) dg)
pragma(msg, typeof(bar)); // void(const(void delegate()) dg)
Therefore, it seems to me that the mangling difference is just for backward compatibility. It is almost redundant, but does not existing code...
Comment #2 by issues.dlang — 2012-10-04T11:23:32Z
scope is _supposed_ to affect all reference types. The fact that it doesn't is a bug in dmd.
Regardless, I would have expected that in would literally be replaced with const scope during the compilation process rather than using it directly in any way. And given that in is supposed to be an alias for const scope, the fact that in is being handled directly rather than being converted to const scope before being processed probably should be changed.
Comment #3 by yebblies — 2013-11-24T06:02:12Z
*** This issue has been marked as a duplicate of issue 8695 ***