http://d.puremagic.com/issues/show_bug.cgi?id=8767

           Summary: expression of type bool() does not have a boolean
                    value?
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: blo...@hotmail.com


--- Comment #0 from Christopher Crouzet <blo...@hotmail.com> 2012-10-05 
20:13:57 PDT ---
Please consider the code below:

// ------------------------------
enum Storage : int
{
  dynamic = 0
}

enum StorageOrder : int
{
  columnMajor = 0,
  rowMajor = 1
}
alias StorageOrder.columnMajor defaultStorageOrder;


class Array( T_scalar, T_args ... )
{
  alias ArrayTraits!( T_scalar, T_args ) traits;
}


class ArrayTraits( T_scalar, T_args ... )
{
  static if ( hasFlag!( Flags.storageOrder ) )
    alias T_args[0 .. $ - 1] shapeTuple;
  else
    alias T_args shapeTuple;

  static immutable StorageOrder storageOrder = hasFlag!( Flags.storageOrder ) ?
      T_args[$ - 1] : defaultStorageOrder;


  static int getFlags()
  {
    int flags = 0;
    if ( is( typeof( T_args[$ - 1] ) == StorageOrder ) )
      flags |= Flags.storageOrder;

    return flags;
  }

  static bool hasFlag( Flags flag )()
  {
    return (getFlags() & flag) != 0;
  }


  enum Flags : int
  {
    dynamic = 1 << 0,
    storageOrder = 1 << 1
  }
}


void main()
{
  auto array1d = new Array!( float, 3 );
}
// ------------------------------

It triggers a compilation error, which is:
/home/c189/c597.d(23): Error: expression hasFlag!(cast(Flags)2) of type bool()
does not have a boolean value

It can be fixed in the code by changing the erroring line to:
static if ( hasFlag!( Flags.storageOrder ) == true )
but I don't really understand why the comparison to true must be explicitely
written since the hasFlag() method returns a bool value?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to