static arrays don't have indirections#6322
Conversation
046e6ea to
fad7dd9
Compare
| { | ||
| int b; | ||
| return foo6(&b); | ||
| } |
There was a problem hiding this comment.
Looks like this is not related, according to the P.R.'s title ?
test/fail_compilation/retscope.d
Outdated
| struct S7 | ||
| { | ||
| int[10] a; | ||
| int[3] abc(int i) |
There was a problem hiding this comment.
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.
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.
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.
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.
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.