Bug 11491 – @safe prefix allows procedures without return type

Status
RESOLVED
Resolution
DUPLICATE
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-11-10T01:23:00Z
Last change time
2013-11-16T23:08:31Z
Assigned to
nobody
Creator
burg.basile

Comments

Comment #0 by burg.basile — 2013-11-10T01:23:32Z
description: ----------- A missing "void" keyword is not detected by dmd 2.064.2 when the function is prefixed with the @safe, @trusted or @system attribute. The error message "function declaration without return type" is not displayed. verified on: ----------- dmd 2.064.2, win7 all the other d2 compiler currently defined at DPaste. other infos: ----------- - the problem doesn't append with an UDA. - the problem doesn't append if the attribute is put after the declaration. example: ------- --- import std.stdio; import std.traits; // void KW is missing but it compiles. template foo(T) { @safe a(out int param) { param = 654564; } @trusted b(out int param) { param = 654564; } @system c(out int param) { param = 654564; } } /* //void KW is missing and it doesn't compile. template bar(T) { a(out int param) @safe { param = 654564; } }*/ void main(string[] args) { int p = 0; foo!int.a(p); writeln(p); assert( isSafe!(foo!int.a) ); /*p = 0; bar!int.a(p);*/ } ---
Comment #1 by bearophile_hugs — 2013-11-10T02:12:11Z
I think this is not a bug, and this issue should be closed. Think of it as a feature, that saves you a bit of code. I think this feature doesn't make the D code more bug-prone.
Comment #2 by andrej.mitrovich — 2013-11-10T09:27:31Z
It's a dupe report (can't find it right now), and it's highly debated in the community whenever it pops up.
Comment #3 by yebblies — 2013-11-16T23:08:31Z
*** This issue has been marked as a duplicate of issue 3573 ***