Bug 17570 – Misleading error message illegal conditional function definition
Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-06-29T05:03:07Z
Last change time
2018-02-17T13:15:38Z
Keywords
diagnostic
Assigned to
No Owner
Creator
Shachar Shemesh
Comments
Comment #0 by shachar — 2017-06-29T05:03:07Z
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.
Comment #1 by razvan.nitu1305 — 2018-02-14T12:51:53Z