Array Locator Methods within Constraints

For an Unpacked Array ::
max() returns the element with the maximum value or whose expression evaluates to a maximum

I understand that max() returns an Unpacked Array so I used Bit-Casting to use max() within a Constraint ::


class MAX ;
 
  rand bit [3:0] b[10] ;

  constraint MAX_ELEMENT { b.sum() with ( int'( item == int'( b.max() )  )  ) == 1 ; }  // Throws Compilation Error !!

endclass


[1] I understand that Constraint blocks ONLY except Integral expressions , but shouldn’t the bit-stream cast work ??

[2] Since min() and max() methods return a Single Element , I was of the Opinion that I can use them in Constraints whereas ALL the Other Array Locator
Methods would be Illegal
( Since they return a Queue !! )

Any Thoughts ??

In reply to TC_2017:

The min() and max() methods could return a single element or the empty array. The rules would have to become much more verbose to allow cases where the locator method returns 1 and only 1 element.