@@ -120,9 +120,6 @@ public Optional<QueryPredicate> toQueryPredicate(@Nullable final TypeRepository
120120            return  compileTimeEvalMaybe (typeRepository );
121121        }
122122
123-         final  var  isLiteralList  = inArrayValue .getCorrelatedTo ().isEmpty ();
124-         SemanticException .check (isLiteralList , SemanticException .ErrorCode .UNSUPPORTED );
125- 
126123        if  (typeRepository  != null ) {
127124            final  var  literalValue  = Preconditions .checkNotNull (inArrayValue .evalWithoutStore (EvaluationContext .forTypeRepository (typeRepository )));
128125            return  Optional .of (new  ValuePredicate (probeValue , new  Comparisons .ListComparison (Comparisons .Type .IN , (List <?>)literalValue )));
@@ -221,26 +218,31 @@ private static Value encapsulateInternal(@Nonnull final List<? extends Typed> ar
221218
222219            final  Typed  arg1  = arguments .get (1 );
223220            final  Type  res1  = arg1 .getResultType ();
224-             SemanticException .check (res1 .isArray (), SemanticException .ErrorCode .INCOMPATIBLE_TYPE );
221+             SemanticException .check (res1 .isArray () || res0 .isArray (), SemanticException .ErrorCode .INCOMPATIBLE_TYPE );
222+ 
223+             final  Type  arrayType  = res0 .isArray () ? res0  : res1 ;
224+             final  Typed  arrayArg  = res0 .isArray () ? arg0  : arg1 ;
225+             final  Type  operandType  = res0 .isArray () ? res1  : res0 ;
226+             final  Typed  operandArg  = res0 .isArray () ? arg1  : arg0 ;
225227
226-             final  var  arrayElementType  = Objects .requireNonNull (((Type .Array ) res1 ).getElementType ());
227-             if  (!arrayElementType .isUnresolved () && res0 .getTypeCode () != arrayElementType .getTypeCode ()) {
228-                 final  var  maximumType  = Type .maximumType (arg0 . getResultType () , arrayElementType );
228+             final  var  arrayElementType  = Objects .requireNonNull (((Type .Array ) arrayType ).getElementType ());
229+             if  (!arrayElementType .isUnresolved () && operandType .getTypeCode () != arrayElementType .getTypeCode ()) {
230+                 final  var  maximumType  = Type .maximumType (operandType , arrayElementType );
229231                // Incompatible types 
230232                SemanticException .check (maximumType  != null , SemanticException .ErrorCode .INCOMPATIBLE_TYPE );
231233
232234                // Promote arg0 if the resulting type is different 
233-                 if  (!arg0 . getResultType () .equals (maximumType )) {
234-                     return  new  InOpValue (PromoteValue .inject ((Value )arg0 , maximumType ), (Value )arg1 );
235+                 if  (!operandType .equals (maximumType )) {
236+                     return  new  InOpValue (PromoteValue .inject ((Value )operandArg , maximumType ), (Value )arrayArg );
235237                } else  {
236-                     return  new  InOpValue ((Value )arg0 , PromoteValue .inject ((Value )arg1 , new  Type .Array (maximumType )));
238+                     return  new  InOpValue ((Value )operandArg , PromoteValue .inject ((Value )arrayArg , new  Type .Array (maximumType )));
237239                }
238240            }
239241
240-             if  (res0 .isRecord ()) {
242+             if  (operandType .isRecord ()) {
241243                // we cannot yet promote this properly 
242244                SemanticException .check (arrayElementType .isRecord (), SemanticException .ErrorCode .INCOMPATIBLE_TYPE );
243-                 final  var  probeElementTypes  = Objects .requireNonNull (((Type .Record )res0 ).getElementTypes ());
245+                 final  var  probeElementTypes  = Objects .requireNonNull (((Type .Record )operandType ).getElementTypes ());
244246                final  var  inElementTypes  = Objects .requireNonNull (((Type .Record )arrayElementType ).getElementTypes ());
245247                for  (int  i  = 0 ; i  < inElementTypes .size (); i ++) {
246248                    final  var  probeElementType  = probeElementTypes .get (i );
@@ -251,7 +253,7 @@ private static Value encapsulateInternal(@Nonnull final List<? extends Typed> ar
251253                            SemanticException .ErrorCode .INCOMPATIBLE_TYPE );
252254                }
253255            }
254-             return  new  InOpValue ((Value )arg0 , (Value )arg1 );
256+             return  new  InOpValue ((Value )operandArg , (Value )arrayArg );
255257        }
256258    }
257259
0 commit comments