June 23, 2012 [Issue 8289] New: Cannot declare functions returning anonymous enum if they have 'in' block. | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=8289 Summary: Cannot declare functions returning anonymous enum if they have 'in' block. Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: minor Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: mp81ss@rambler.ru --- Comment #0 from Michele Pes <mp81ss@rambler.ru> 2012-06-23 07:11:50 PDT --- import std.stdio; enum { A, B }; /* If I replace the return type int with enum, doesn't compile. If I remove the in/body blocks and declare a contractless f, both enum/int are ok. */ int dummy(in int i) in { assert(i > 0); } body { return A; } void main() { immutable x = dummy(0); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 02, 2012 [Issue 8289] Cannot declare functions returning anonymous enum if they have 'in' block. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Michele Pes | http://d.puremagic.com/issues/show_bug.cgi?id=8289 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |andrej.mitrovich@gmail.com Resolution| |INVALID --- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-12-02 06:07:23 PST --- Maybe you're misreading the runtime assert error as a compiler error? OTOH if you're trying to declare the return type as 'A', that won't work because A is not a type. Unfortunately DMD allows nonsense like this: enum dummy(in int i) { } The 'enum' here acts as a placeholder as if you've declared it 'auto'. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation