1.2.26. test/regress/rt-1.01.26

     1: #line 996 "./lpsrc/flx_regress.pak"
     2: //Check type constraints
Start felix section to test/regress/rt-1.01.26-0.flx[1 /1 ]
     3: #import <flx.flxh>
     4: open C_hack;
     5: header '#include <iostream>';
     6: proc pr[t]:t="std::cout<<$1<<std::endl;";
     7: 
     8: var x = 1;
     9: var px:ptr[int] = addr x;
    10: 
    11: module X {
    12:   proc h[t,u=ptr[t]]: u  * t = '*$1=$2; std::cout <<*$1<<","<<$2<<std::endl;';
    13:   h(px,1);
    14: 
    15:   // address and dereference operators where
    16:   // constraint is required to deduce type variable
    17:   // (artificial example, since we could write signatures
    18:   // directly in terms of t)
    19:   fun adr[t,u=ptr[t]]: lvalue[t]->u = "&$1";
    20:   fun drf[t,u=ptr[t]]:  u -> t = "*$1";
    21:   //h(px,1.1); // should fail
    22: }
    23: 
    24: open X[int];
    25: h(px,1);
    26: //h(px,1.1); // should fail
    27: 
    28: pr$ drf px;
    29: pr$ drf$ adr x;
    30: pr$ X::drf px;
    31: pr$ X::drf$ X::adr x;
    32: 
    33: fun ff[t,k where t==k ]: t * k -> t = "$1+$2";
    34: 
    35: pr$ ff$ 1,2;
    36: //pr$ ff$ 1,2.0; // should fail
End felix section to test/regress/rt-1.01.26-0.flx[1]
Start data section to test/regress/rt-1.01.26-0.expect[1 /1 ]
     1: 1,1
     2: 1,1
     3: 1
     4: 1
     5: 1
     6: 1
     7: 3
End data section to test/regress/rt-1.01.26-0.expect[1]