Buggy code:
public class GFLWOR extends ParseExpr { Expr ret ; ForLet [ ] fl ; Expr where ; private Order order ; private final Group group ; GFLWOR ( final ForLet [ ] f , final Expr w , final Order o , final Group g , final Expr r , final InputInfo ii ) { } public static GFLWOR get ( final ForLet [ ] f , final Expr w , final OrderBy [ ] o , final Var [ ] [ ] g , final Expr r , final InputInfo ii ) { } @ Override public Expr comp ( final QueryContext ctx ) throws QueryException { compHoist ( ctx ) ; compWhere ( ctx ) ; final boolean grp = ctx . grouping ; ctx . grouping = ( group ) != null ; final int vs = ctx . vars . size ( ) ; for ( int f = 0 ; f < ( fl . length ) ; ++ f ) { final ForLet flt = fl [ f ] ; flt . comp ( ctx ) ; if ( ( flt . expr . isValue ( ) ) || ( ( count ( flt . var , f ) ) == 1 ) ) flt . bind ( ctx ) ; } boolean empty = false ; if ( ( where ) != null ) { where = checkUp ( where , ctx ) . comp ( ctx ) . compEbv ( ctx ) ; if ( where . isValue ( ) ) { empty = ! ( where . ebv ( ctx , input ) . bool ( input ) ) ; if ( ! empty ) { ctx . compInfo ( OPTREMOVE , description ( ) , where ) ; where = null ; } } } if ( ( group ) != null ) group . comp ( ctx ) ; if ( ( order ) != null ) order . comp ( ctx ) ; ret = ret . comp ( ctx ) ; ctx . vars . size ( vs ) ; ctx . grouping = grp ; if ( empty ) { ctx . compInfo ( OPTREMOVE , description ( ) , where ) ; return Empty . SEQ ; } if ( ( ret ) == ( Empty . SEQ ) ) { ctx . compInfo ( OPTFLWOR ) ; return ret ; } for ( int f = 0 ; f < ( fl . length ) ; ++ f ) { final ForLet l = fl [ f ] ; if ( ( ( l . var . expr ( ) ) != null ) || ( ( ( l . simple ( true ) ) && ( ( count ( l . var , f ) ) == 0 ) ) && ( ! ( l . expr . uses ( NDT ) ) ) ) ) { ctx . compInfo ( OPTVAR , l . var ) ; fl = Array . delete ( fl , ( f -- ) ) ; } } if ( ( fl . length ) == 0 ) { ctx . compInfo ( OPTFLWOR ) ; return ( where ) != null ? new org . basex . query . expr . If ( input , where , ret , Empty . SEQ ) : ret ; } for ( final ForLet f : fl ) { <START_BUG> if ( ( f instanceof For ) && ( f . isEmpty ( ) ) ) { <END_BUG> ctx . compInfo ( OPTFLWOR ) ; return Empty . SEQ ; } } if ( ( ( where ) == null ) && ( ( group ) == null ) ) { size = ret . size ( ) ; if ( ( size ) != ( - 1 ) ) { for ( final ForLet f : fl ) { final long s = f . size ( ) ; if ( s == ( - 1 ) ) { size = s ; break ; } size *= s ; } } } type = SeqType . get ( ret . type ( ) . type , size ) ; compHoist ( ctx ) ; return this ; } private void compHoist ( final QueryContext ctx ) { } private void compWhere ( final QueryContext ctx ) { } @ Override public Iter iter ( final QueryContext ctx ) throws QueryException { } private void iter ( final QueryContext ctx , final Iter [ ] it , final int p , final ObjList < Item [ ] > ks , final ValueList vs ) throws QueryException { } @ Override public final boolean uses ( final Use u ) { } @ Override public final int count ( final Var v ) { } final int count ( final Var v , final int i ) { } @ Override public final boolean removable ( final Var v ) { } @ Override public final Expr remove ( final Var v ) { } @ Override public final void plan ( final Serializer ser ) throws IOException { } @ Override public final String toString ( ) { } }

Fix:
if ( ( f instanceof For ) && ( ( f . size ( ) ) == 0 ) ) {