www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17570] New: Misleading error message illegal conditional

https://issues.dlang.org/show_bug.cgi?id=17570

          Issue ID: 17570
           Summary: Misleading error message illegal conditional function
                    definition
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: shachar weka.io

Consider the following program:
import std.traits;

struct S(T) {
    void func() if(isIntegral!T) {
    }
}

Currently, it produces the following error message:
test.d(4): Error: semicolon expected following function declaration
test.d(4): Error: declaration expected, not 'if'
test.d(7): Error: } expected following members in struct declaration at
test.d(3)

The error message it should be producing is:
test.d(4): Error: cannot use conditional definition for non-template functions.
Use "static if" instead.

--
Jun 28