-
-
Notifications
You must be signed in to change notification settings - Fork 667
static arrays don't have indirections #6322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
046e6ea to
fad7dd9
Compare
| { | ||
| int b; | ||
| return foo6(&b); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is not related, according to the P.R.'s title ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we need to review #6321 first.
test/fail_compilation/retscope.d
Outdated
| struct S7 | ||
| { | ||
| int[10] a; | ||
| int[3] abc(int i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is not @safe, hence scope is not enforced here. I got bit by this many times, hence why I so strongly argued for scope being enforced everywhere.
I would also add the following test cases:
int[3] test1 (scope int[] p) @safe { return p[0 .. 3]; } // Do not error because there isn't any indirection
char*[3] test1 (scope char*[] p) @safe { return p[0 .. 3]; } // Error here because there is an indirectionThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it change the design to extend scope checks (without scope inference) to unsafe code later on?
If not we could defer this decision and discussion.
Added it to the scope/DIP1000 backlog https://trello.com/c/XT4RECah/96-spec-how-to-extend-scope-checks-to-unsafe-code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int[3] test1 (scope int[] p) @safe { return p[0 .. 3]; } // Do not error because there isn't any indirection
added
char*[3] test1 (scope char*[] p) @safe { return p[0 .. 3]; } // Error here because there is an indirection
scope is not transitive, so the indirection is not covered by it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scopeis not transitive, so the indirection is not covered by it.
So this should not error ? If so, please add the test case as well.
Also, abc is still missing @safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this should not error ?
That's right.
If so, please add the test case as well. Also, abc is still missing @safe.
done
03a1112 to
c23b953
Compare
c23b953 to
519aec3
Compare
No description provided.