Thread overview
[Issue 772] New: Bogus error using relation operator as static if expression within template
Dec 30, 2006
d-bugmail
Dec 31, 2006
d-bugmail
Jan 04, 2007
d-bugmail
Jul 24, 2008
d-bugmail
Nov 08, 2008
d-bugmail
December 30, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=772

           Summary: Bogus error using relation operator as static if
                    expression within template
           Product: D
           Version: 0.178
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: ibisbasenji@gmail.com


Given the following useless test program...
--------------------------------------------------
module bug ;

template foo (ulong n) {
  static if (n < 10_LU) {
    const foo = n ;
  }
  else {
    const foo = n % 10 ;
  }
}

void main () {
  ulong a = 1_LU ;

  auto omega = foo!(a);
}
--------------------------------------------------

The compiler will output:
bug.d(4): Error: expression (a) < 10LU does not evaluate to a boolean
bug.d(15): template instance bool0.main.foo!(a) error instantiating


-- 

December 31, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=772





------- Comment #1 from thomas-dloop@kuehne.cn  2006-12-31 08:47 -------
Added to DStress as http://dstress.kuehne.cn/compile/o/opCmp_09_A.d http://dstress.kuehne.cn/compile/o/opCmp_09_B.d http://dstress.kuehne.cn/nocompile/o/opCmp_09_C.d http://dstress.kuehne.cn/run/o/opCmp_09_D.d


-- 

January 04, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=772


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #2 from bugzilla@digitalmars.com  2007-01-03 22:54 -------
Fixed DMD 1.00


-- 

July 24, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=772


davidl@126.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |




------- Comment #3 from davidl@126.com  2008-07-24 08:57 -------
seems regression on dmd 1.033


-- 

November 08, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=772


gide@nwawudu.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |INVALID




------- Comment #4 from gide@nwawudu.com  2008-11-08 12:34 -------
const should be added to the variable declaration, so the error message is correct. Add const and it works in DMD 2.020 and 1.033.

module bug ;

template foo (ulong n) {
  static if (n < 10_LU) {
    const foo = n ;
  }
  else {
    const foo = n % 10 ;
  }
}

void main () {
  const ulong a = 1_LU ; // <- added const

  auto omega = foo!(a);
}


--