www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12553] New: compilation fails if a forward referenced symbol

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

          Issue ID: 12553
           Summary: compilation fails if a forward referenced symbol
                    represents a value and is first used as template
                    parameter
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: 2krnk gmx.net

/++
if a forward referenced symbol is first used as template parameter, then
compilation fails for symbols that represent values.
(no problems with symbols representing funcs, structs, classes and empty
enums.)
++/

//any of the following will make the bug(s) disappear:
//  enum fix = test;
//  enum fix2 = test2;
//  pragma(msg, __traits(compiles, test) );
//  pragma(msg, __traits(compiles, test2) );

enum buggy = check!(test);
enum buggy2 = check2!(test2);
//Error: variable buggy(2) had semantic errors when compiling

enum test = 13;     // fails
enum test2 = 13;     // fails
//  immutable test = 13;// fails
//  const test = 13;    // fails
//BUT no problems whatsover with symbols not representing values:
//  enum test;          // works
//  void test(){}       // works
//  struct test{}       // works
//  class test{}        // works

template check(alias sym){
    enum check = true;
} // no difference if this template is declared first
template check2(int sym){
    enum check2 = true;
} // no difference if this template is declared first

void main(){}

--
Apr 09 2014