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
void main()
{
int i = 42;
// const should not be able to access mutable.
int* p = &i;
auto dg2 = delegate int() const { return *p; };
assert(dg2() == i);
}
fails to error.
Also
void main()
{
int i = 42;
// shared cannot access mutable
int* p = &i;
auto dg2 = delegate int() shared { return *p; };
assert(dg2() == i);
}
errors, the context should be captured as shared so that should be allowed. Issue 15306 declared this accepts invalid as shared aliasing but I believe that is incorrect. Shared doesn't offer any useful guaruntees on that front anyway.
The text was updated successfully, but these errors were encountered:
iamthewilsonator commented on 2019-06-17T12:55:12Z
So the real issue is:
struct S
{
int x;
void foo() const
{
pragma(msg, typeof(x)); // const(int)
}
}
void test()
{
void nested() const
{
pragma(msg, typeof(x)); // int
}
}
Nicholas Wilson (@thewilsonator) reported this on 2019-06-14T08:05:25Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=19961
CC List
Description
void main() { int i = 42; // const should not be able to access mutable. int* p = &i; auto dg2 = delegate int() const { return *p; }; assert(dg2() == i); } fails to error. Also void main() { int i = 42; // shared cannot access mutable int* p = &i; auto dg2 = delegate int() shared { return *p; }; assert(dg2() == i); } errors, the context should be captured as shared so that should be allowed. Issue 15306 declared this accepts invalid as shared aliasing but I believe that is incorrect. Shared doesn't offer any useful guaruntees on that front anyway.The text was updated successfully, but these errors were encountered: