You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#include "share/atspre_staload.hats"
fun foldl{a,b:t@ype}(f: (a, b) -> a, acc: a, list: List(b)): a =
case+ list of
| list_nil() => acc
| list_cons(x, xs) => foldl(f, f(acc, x), xs)
implement main0() =
let
val list = $list{int}(1, 2, 3, 4, 5)
//val sum = foldl(lam (acc, n) => acc + n, 0, list)
val sum = foldl(f, 0, list): int where {
fun f(a: int, b: int): int = a + b
}
in
println!("sum1: ", sum);
end
Fails to compile with these errors:
patscc -DATS_MEMALLOC_GCBDW -o foldlgc foldlgc.dats -latslib -lgc
foldlgc_dats.c:317:1: error: ‘foldl_0’ declared as function returning an array
foldl_0(atstype_funptr, atstyvar_type(a), atstype_boxed) ;
^~~~~~~
foldlgc_dats.c:340:1: error: ‘foldl_0’ declared as function returning an array
foldl_0(atstype_funptr arg0, atstyvar_type(a) arg1, atstype_boxed arg2)
^~~~~~~
In file included from foldlgc_dats.c:15:0:
foldlgc_dats.c: In function ‘foldl_0’:
/home/fondren/sea/ats/ATS2/ccomp/runtime/pats_ccomp_instrset.h:276:35: error: assignment to expression with array type
#define ATSINSmove(tmp, val) (tmp = val)
^
foldlgc_dats.c:385:1: note: in expansion of macro ‘ATSINSmove’
ATSINSmove(tmpret0, arg1) ;
^~~~~~~~~~
/home/fondren/sea/ats/ATS2/ccomp/runtime/pats_ccomp_instrset.h:276:35: error: assignment to expression with array type
#define ATSINSmove(tmp, val) (tmp = val)
^
foldlgc_dats.c:406:1: note: in expansion of macro ‘ATSINSmove’
ATSINSmove(tmp1, ATSSELcon(arg2, postiats_tysum_0, atslab__0)) ;
^~~~~~~~~~
foldlgc_dats.c:420:1: error: type name declared as function returning an array
ATSINSmove(tmp3, ATSfunclo_fun(arg0, (atstyvar_type(a), atstyvar_type(b)), atstyvar_type(a))(arg1, tmp1)) ;
^~~~~~~~~~
In file included from foldlgc_dats.c:15:0:
/home/fondren/sea/ats/ATS2/ccomp/runtime/pats_ccomp_instrset.h:276:35: error: assignment to expression with array type
#define ATSINSmove(tmp, val) (tmp = val)
^
foldlgc_dats.c:420:1: note: in expansion of macro ‘ATSINSmove’
ATSINSmove(tmp3, ATSfunclo_fun(arg0, (atstyvar_type(a), atstyvar_type(b)), atstyvar_type(a))(arg1, tmp1)) ;
^~~~~~~~~~
/home/fondren/sea/ats/ATS2/ccomp/runtime/pats_ccomp_instrset.h:320:41: error: assignment to expression with array type
#define ATSINSmove_tlcal(apy, tmp) (apy = tmp)
^
foldlgc_dats.c:427:1: note: in expansion of macro ‘ATSINSmove_tlcal’
ATSINSmove_tlcal(apy1, tmp3) ;
^~~~~~~~~~~~~~~~
/home/fondren/sea/ats/ATS2/ccomp/runtime/pats_ccomp_instrset.h:97:28: warning: return makes integer from pointer without a cast [-Wint-conversion]
#define ATSreturn(x) return(x)
^
foldlgc_dats.c:443:1: note: in expansion of macro ‘ATSreturn’
ATSreturn(tmpret0) ;
^~~~~~~~~
/home/fondren/sea/ats/ATS2/ccomp/runtime/pats_ccomp_instrset.h:97:28: warning: function returns address of local variable [-Wreturn-local-addr]
#define ATSreturn(x) return(x)
^
foldlgc_dats.c:443:1: note: in expansion of macro ‘ATSreturn’
ATSreturn(tmpret0) ;
^~~~~~~~~
Makefile:13: recipe for target 'foldlgc' failed
make: *** [foldlgc] Error 1
The text was updated successfully, but these errors were encountered:
This foldl with some usage:
Fails to compile with these errors:
The text was updated successfully, but these errors were encountered: