www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22134] New: Deprecate returning a void value from a function


          Issue ID: 22134
           Summary: Deprecate returning a void value from a function
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ibuclaw gdcproject.org

For example: libdparse has an opIndex returning the value of a `void[]`.


struct StackBuffer
    auto opIndex(size_t i)
        return arr[i];

    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

Jul 21 2021