www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20777] New: User defined types as anonymous enums basetype,

https://issues.dlang.org/show_bug.cgi?id=20777

          Issue ID: 20777
           Summary: User defined types as anonymous enums basetype, fail
                    to compile.
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: crazymonkyyy gmail.com

struct fooint{
  enum isfoo=true;
  enum isbar=false;
  int i;
  auto opBinary(string op:"+")(int j){
    return fooint(i+j);
  }
  alias i this;
   property fooint max(){return fooint(int.max);}
}
static assert(fooint(0)+1 != fooint(0).max);
static assert(fooint(0)+1 != fooint(0));
enum foolist {hi=fooint(0),bye,fizz,buzz}
//no property max for type fooint, did you mean bar.fooint.max
"If there is no AssignExpression and it is not the first EnumMember, it is given the value of the previous EnumMember+1. If the value of the previous EnumMember is the .max property if the previous EnumMember's type, it is an error. If the value of the previous EnumMember+1 is the same as the value of the previous EnumMember, it is an error." --
Apr 27 2020