Type pattern with constraint on argument types not working
If I try this example:
use Array: all;
int[m] foo ( int[n] v, int[m] w) | ( n == 2 * m)
{
return { iv -> v[iv*2] + w[iv] | iv < [m]};
}
int main () {
a = foo( [1,2,3], [1,2]);
return _sel_VxA_([1], a);
}
using
sac2c 1.3.3-MijasCosta-1115-g81576
build-type: RELEASE
built-by: "sbs" at 2023-11-29T11:50:22
with sac2c -check c -b2:rtpf
we obtain:
/****************************************************************************
* _rtpf_2_post_foo(...) [ body ]
****************************************************************************/
inline
bool _rtpf_2_post_foo( int[.] v { ,NN } , int[.] w { ,NN } , int[.] _rtpf_1_ret { ,NN } )
/*
* _rtpf_2_post_foo :: ---
*/
{
_rtpf_0_pred = true;
n = _sel_VxA_( [ 0 ], _shape_A_( v));
m = _sel_VxA_( [ 0 ], _shape_A_( w));
_rtpf_0_pred = ( _eq_SxS_( m, _sel_VxA_( [ 0 ], _shape_A_( _rtpf_1_ret))) ? _rtpf_0_pred : _type_error_( _|_) );
return( _rtpf_0_pred);
}
/****************************************************************************
* _rtpf_3_impl_foo(...) [ body ]
****************************************************************************/
int[.] _rtpf_3_impl_foo( int[.] v { ,NN } , int[.] w { ,NN } )
/*
* _rtpf_3_impl_foo :: ---
*/
{
n = _sel_VxA_( [ 0 ], _shape_A_( v));
m = _sel_VxA_( [ 0 ], _shape_A_( w));
return( { iv -> ( sel( ( iv *2) , v) +sel( iv, w) ) | (NULL) <= ? < [ m ] });
}
/****************************************************************************
* foo(...) [ body ]
****************************************************************************/
inline
int[.] foo( int[.] v { ,NN } , int[.] w { ,NN } )
/*
* foo :: ---
*/
{
_rtpf_5_res = _rtpf_3_impl_foo( v, w) ;
_rtpf_4_pred = _rtpf_2_post_foo( v, w, _rtpf_5_res) ;
_rtpf_5_res = _guard_( _rtpf_5_res, _rtpf_4_pred);
return( _rtpf_5_res);
}
Note here the missing pre-check!