You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following shows the problem:
---------------------
struct S {
const int[] x;
const int[] y;
const int z;
this(int i) { x = null; // works foo(y); // fails bar(z); // works}
}
void foo(out int[] y) { y = null; }
void bar(out int z) { z = 1; }
---------------------
dmd -c foo
foo.d(9): Error: function foo.foo (out int[] y) is not callable using argument types (const(int[]))
The text was updated successfully, but these errors were encountered:
(In reply to comment #0)
> The following shows the problem:> ---------------------> struct S {> const int[] x;> const int[] y;> const int z;> > this(int i) {> x = null; // works> foo(y); // fails> bar(z); // works> }> }> > void foo(out int[] y) { y = null; }> > void bar(out int z) { z = 1; }> ---------------------
I think bar(z); should also be rejected, because it would violate const system.
struct S
{
immutable int z;
this(int i){ bar(z); // works}
}
int* g;
void bar(out int z) { z = 1; g = &z; }
void main()
{
S s = S(1);
assert(s.z == 1 && is(typeof(s.z) == immutable int));
*g = 100;
assert(s.z == 1); // fails!
}
Walter Bright (@WalterBright) reported this on 2013-12-14T11:08:45Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=11743
Description
The text was updated successfully, but these errors were encountered: