Function Delegation Causing Assert Failed

26 views
Skip to first unread message

aditya siram

unread,
Aug 31, 2017, 12:12:42 PM8/31/17
to ats-lang-users
Hi,
I'm trying to delegate my pointer setting function to `aptr_set_elt`. I just copied the source from `pointer.sats/pointer.dats` and delegated for the implementation:

extern fun
{a:vt0p}
my_aptr_set_elt
 
{l:agz}
 
(ap: !aptr(a?, l) >> aptr(a, l), x: a):<!wrt> void

implement
{a}
my_aptr_set_elt
 
(ap, x) = aptr_set_elt<a>(ap, x)


When I try to compile I get an error from the generated C code about a failed assertion:
 
patscc -D_GNU_SOURCE -DATS_MEMALLOC_LIBC -I${PATSHOME}/contrib -o foo_dats foo.dats -latslib -g |& pats-filter


exit(ATS): [assert] failed: /home/hwxi/Research/ATS-Postiats/src/pats_ccomp_dynexp.dats: 20471(line=893, offs=16) -- 20487(line=893, offs=32)

Any idea what I'm doing wrong here?
Thanks!

aditya siram

unread,
Aug 31, 2017, 12:24:20 PM8/31/17
to ats-lang-users
I also tried doing it in one shot:
fun
{a:vt0p}
my_aptr_set_elt
 
{l:agz}

 
(ap: !aptr(a?, l) >> aptr(a, l), x: a):<!wrt> void = aptr_set_elt<a>(ap, x)

and now I get:
foo.dats:21:1: a termination metric is missing

aditya siram

unread,
Aug 31, 2017, 1:54:34 PM8/31/17
to ats-lang-users
The first attempt actually works. I unfortunately had a

println! $myfunction

in the file that caused this issue.

Sorry for the noise.

gmh...@gmail.com

unread,
Aug 31, 2017, 2:02:59 PM8/31/17
to aditya...@gmail.com, ats-lan...@googlegroups.com

Please try 'fn' instead of 'fun'.


Sent from my T-Mobile 4G LTE device


------ Original message------

From: aditya siram

Date: Thu, Aug 31, 2017 1:24 PM

To: ats-lang-users;

Subject:Re: Function Delegation Causing Assert Failed


--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/3110014a-2eb3-4fd5-868a-5ff6090c9d1c%40googlegroups.com.

aditya siram

unread,
Aug 31, 2017, 2:33:04 PM8/31/17
to ats-lang-users, aditya...@gmail.com
That worked! So why is 'fn' required here to signify a non-recursive function while the original source uses 'fun' but doesn't provide a termination metric?

gmh...@gmail.com

unread,
Aug 31, 2017, 3:18:44 PM8/31/17
to aditya...@gmail.com, ats-lan...@googlegroups.com

If use 'fun', the ntm effect (non-termination) is assumed. In your case, you only mentioned the wrt effect.


Sent from my T-Mobile 4G LTE device


------ Original message------

From: aditya siram

Date: Thu, Aug 31, 2017 3:33 PM

To: ats-lang-users;

Cc: aditya...@gmail.com;

Reply all
Reply to author
Forward
0 new messages