Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions changelog/discourage_in.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
`in` as parameter storage class is temporarily discouraged

`in` as a parameter storage class is defined as `scope const`. However `in` has not yet
been properly implemented so its current implementation is equivalent to `const`. Properly
implementing `in` now will likely break code, so it is recommended to avoid using `in`, and
explicitly use `const` or `scope const` instead, until `in` is properly implemented.

---
void f(in ref T t); // Deprecation: `in` is defined as `scope const`. However, `in` has not
// yet been properly implemented, so its current implementation is equivalent to
// `const`. It is recommended to avoid using `in`, and explicitly use `scope
// const` or `const` instead, until `in` is properly implemented.
---

Beginning with this release, any usage of `in` as a parameter storage class will result in a
deprecation message. Replace `in` with `const` or `scope const` until a future release provides a
proper implementation of `in`.
8 changes: 8 additions & 0 deletions src/dmd/parse.d
Original file line number Diff line number Diff line change
Expand Up @@ -2901,6 +2901,14 @@ final class Parser(AST) : Lexer
}
case TOK.in_:
stc = AST.STC.in_;
// @@@DEPRECATED_2.094@@@
// Deprecated in 2.088
// Remove this message after sufficient time has passed (e.g. 1 or 2 years) so `in` can be
// properly implemented as `scope const` without too much risk of breakage
deprecation("`in` is defined as `scope const`. However, `in` has not yet been properly " ~
"implemented, so its current implementation is equivalent to `const`. It is recommended " ~
"to avoid using `in`, and explicitly use `scope const` or `const` instead, until `in` " ~
"is properly implemented.");
goto L2;

case TOK.out_:
Expand Down
4 changes: 2 additions & 2 deletions test/compilable/warn3882.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void test3882()
/******************************************/
// https://issues.dlang.org/show_bug.cgi?id=12619

extern (C) @system nothrow pure void* memcpy(void* s1, in void* s2, size_t n);
extern (C) @system nothrow pure void* memcpy(void* s1, const void* s2, size_t n);
// -> weakly pure

void test12619() pure
Expand Down Expand Up @@ -70,7 +70,7 @@ void test12909()

const struct Foo13899
{
int opApply(immutable int delegate(in ref int) pure nothrow dg) pure nothrow
int opApply(immutable int delegate(const ref int) pure nothrow dg) pure nothrow
{
return 1;
}
Expand Down
4 changes: 4 additions & 0 deletions test/fail_compilation/fail183.d
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail183.d(10): Deprecation: `in` is defined as `scope const`. However, `in` has not yet been properly implemented, so its current implementation is equivalent to `const`. It is recommended to avoid using `in`, and explicitly use `scope const` or `const` instead, until `in` is properly implemented.
fail_compilation/fail183.d(10): Deprecation: `in` is defined as `scope const`. However, `in` has not yet been properly implemented, so its current implementation is equivalent to `const`. It is recommended to avoid using `in`, and explicitly use `scope const` or `const` instead, until `in` is properly implemented.
fail_compilation/fail183.d(10): Error: redundant attribute `const`
fail_compilation/fail183.d(10): Deprecation: `in` is defined as `scope const`. However, `in` has not yet been properly implemented, so its current implementation is equivalent to `const`. It is recommended to avoid using `in`, and explicitly use `scope const` or `const` instead, until `in` is properly implemented.
fail_compilation/fail183.d(10): Error: redundant attribute `scope`
fail_compilation/fail183.d(11): Error: redundant attribute `in`
---
*/

#line 10
void f(in final const scope int x) {}
void g(final const scope in int x) {}
2 changes: 1 addition & 1 deletion test/fail_compilation/ice11626.d
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ fail_compilation/ice11626.d(8): Error: undefined identifier `Bar`
---
*/

void foo(in ref Bar) {}
void foo(const ref Bar) {}
2 changes: 1 addition & 1 deletion test/runnable/xtest46.d
Original file line number Diff line number Diff line change
Expand Up @@ -6158,7 +6158,7 @@ static assert(!__traits(compiles, foo8220(typeof(0)))); // fail

/***************************************************/

void func8105(in ref int x) { }
void func8105(const ref int x) { }

void test8105()
{
Expand Down