[Issue 17570] New: Misleading error message illegal conditional function definition

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Jun 28 22:03:07 PDT 2017


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 at puremagic.com
          Reporter: shachar at 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.

--


More information about the Digitalmars-d-bugs mailing list