Bug 8289 – Cannot declare functions returning anonymous enum if they have 'in' block.

Status
RESOLVED
Resolution
INVALID
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-06-23T07:11:00Z
Last change time
2012-12-02T06:07:23Z
Assigned to
nobody
Creator
mp81ss

Comments

Comment #0 by mp81ss — 2012-06-23T07:11:50Z
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); }
Comment #1 by andrej.mitrovich — 2012-12-02T06:07:23Z
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'.