For example: libdparse has an opIndex returning the value of a `void[]`. https://github.com/dlang-community/libdparse/blob/fbdf71b929a9f9bc982d0204f921371806e5d412/src/dparse/stack_buffer.d#L73-L82 --- struct StackBuffer { auto opIndex(size_t i) { return arr[i]; } private: void[] arr; } --- This is clearly a dead function, as any use of it will result in the error: --- Error: variable `var` type void is inferred from initializer `buf.opIndex(0LU)`, and variables cannot be of type void Error: expression buf.opIndex(0LU) is void and has no value ---
To be clear, this is only about void values with no side effects. This is already done with ExpStatement and CommaExp with the use of the `discardValue`.
@ibuclaw created dlang/dmd pull request #12898 "fix Issue 22134 - Deprecate returning a void value from a function" fixing this issue: - fix Issue 22134 - Deprecate returning a void value from a function https://github.com/dlang/dmd/pull/12898
dlang/dmd pull request #12898 "fix Issue 22134 - Deprecate returning a discarded void value from a function" was merged into master: - d6a07ccd0a2ab6ec757d54b40b5b0697a9d54144 by Iain Buclaw: fix Issue 22134 - Deprecate returning a discarded void value from a function https://github.com/dlang/dmd/pull/12898