Hi,
I'm trying to pass and mutate a stack allocated tuple in a string 
processing function:

fn length_last
  {l:nat | l > 1 }
  (
    s: string l
  ): (int, char) =
  let
    var env = (0,s.head())
    implement stream_vt_foreach$fwork<charNZ><(int,charNZ)>(c,env) =
      env := (env.0 + 1, c)
    val _ = stream_vt_foreach_env(
              streamize_string_char(s.tail()),
              env
            )
  in
   env
  end

 The stack allocated 'env' should finally have the length of the string and 
the last character after 'stream_vt_foreach_env' is run. Instead I get 
compile errors like:
length_last.dats:15:13: the dynamic expression should be a left-value but 
it is not.

length_last.dats:11:3: the linear dynamic variable [env$view$5548(-1)] is 
preserved but with an incompatible type.

length_last.dats:11:3: mismatch of static terms (tyleq):

The actual term is: S2Etop(knd=0; [1])
[1]: S2EVar(5260)
The needed term is: S2Etyrec(flt0; npf=-1; 0=S2Etop(knd=0; S2Etop(knd=0; [1
])), 1=S2Etop(knd=0; S2Etop(knd=0; [2])))
[1]: g1int_int_t0ype(int_kind, 0)
[2]: charNZ

length_last.dats:11:3: mismatch of static terms (tyleq):

The actual term is: S2Eat(S2Etop(knd=0; [1]); [2])
[1]: S2EVar(5260)
[2]: env
The needed term is: S2Eat(S2Etyrec(flt0; npf=-1; 0=S2Etop(knd=0; S2Etop(knd=
0; [1])), 1=S2Etop(knd=0; S2Etop(knd=0; [2]))); [3])
[1]: g1int_int_t0ype(int_kind, 0)
[2]: charNZ
[3]: env
patsopt(TRANS3): there are [2] errors in total.
exit(ATS): uncaught exception: 
_2home_2deech_2Downloads_2ATS_2ATS2_2src_2pats_error_2esats__FatalErrorExn(
1025)

Is the problem that I'm passing a stack allocated tuple as the environment?

Thanks!

-- 
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/012ab377-9bd9-401d-b738-b9a3efbfd841%40googlegroups.com.

Reply via email to