Indeed, in this case, the old value of the mutable variable is abandoned.

You could free res first, and then assign.

пн, 28 мая 2018 г., 7:37 aditya siram <[email protected]>:

> In my haste I didn't include the line number of the error but it points to
> 'res := Some_vt(i+1)'.
>
> On Sunday, May 27, 2018 at 8:23:20 PM UTC-5, Artyom Shalkhakov wrote:
>>
>> Hi Aditya,
>>
>> I guess you will need to free it?
>>
>> пн, 28 мая 2018 г., 7:19 aditya siram <[email protected]>:
>>
>>> Hi,
>>> I have the following simplified version of assiging to a stack variable
>>> and am getting the following error:
>>>
>>> "linear component of the following type is abandoned:
>>> [S2Eapp(S2Ecst(option_vt0ype_bool_vtype); S2Eapp(S2Ecst(g0int_t0ype); [1]),
>>> S2Evar(b$8622$8623(14297)))]"
>>>
>>> I searched around and the only reference I see to this error is about
>>> using a global variable in a function scope.
>>>
>>> Any help is appreciated.
>>>
>>> Thanks!
>>> -deech
>>> extern fun add1(
>>>   n : Option_vt(int)
>>> ) : Option_vt(int)
>>>
>>> implement add1(n) =
>>>   let
>>>     fun add1_( n:Option_vt(int), res: &Option_vt(int) >> Option_vt(int)
>>> ) : void =
>>>       case+ n of
>>>         | ~Some_vt(i) => res := Some_vt(i+1)
>>>         | ~None_vt() => ()
>>>     var res : Option_vt(int) = None_vt()
>>>     val () = add1_(n,res)
>>>   in
>>>     res
>>>   end
>>>
>>>
>>> --
>>> 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 [email protected].
>>> To post to this group, send email to [email protected].
>>> 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/e51eb3bb-a5cb-4615-a87b-f2aa275fc5a4%40googlegroups.com
>>> <https://groups.google.com/d/msgid/ats-lang-users/e51eb3bb-a5cb-4615-a87b-f2aa275fc5a4%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> 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/ff7f85a7-7af2-4e57-8fbe-fe9ed80a20f5%40googlegroups.com
> <https://groups.google.com/d/msgid/ats-lang-users/ff7f85a7-7af2-4e57-8fbe-fe9ed80a20f5%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/CAKO6%3DqjVtdR8opu%3Dfa72e22UrkrrLJUVk23i9kOqv8Yd7D5eYg%40mail.gmail.com.

Reply via email to