Dear all,
I'm trying the datavtype for tagged union as following:
```ats
#include "share/atspre_define.hats"
#include "share/atspre_staload.hats"
#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
#define AF_INET6 28 /* IPv6 */
typedef sockaddr_in = @{
sin_port = int,
sin_addr = int,
sin_zero = int
}
typedef sockaddr_in6 = @{
sin6_port = int,
sin6_flowinfo = int,
sin6_addr = int,
sin6_scope_id = int
}
datavtype sockaddr (sa_family: int) =
| Af_inet (AF_INET) of sockaddr_in
| Af_inet6 (AF_INET6) of sockaddr_in6
vtypedef wg_endpoint = [i:int] @{
e_remote = sockaddr(i)
}
fun wg_input
{l1,l2:addr}{i:int}
(pfe: !wg_endpoint@l1, pfso: !sockaddr(i)@l2 | e: ptr l1, so: ptr l2):
void = let
val so = scase i of
| AF_INET => so
| AF_INET6 => so
| _ => null
val () = !e.e_remote := so
in
()
end
implement main0 () = {
var e: wg_endpoint
var so: sockaddr(AF_INET6)
prval pre = view@e
prval prso = view@so
// val () = wg_input(pre, prso | e, so)
prval () = view@e := pre
prval () = view@so := prso
}
```
But above code causes following error:
```
$ patscc -o a.out main.dats -DATS_MEMALLOC_LIBC
.../main.dats: 680(line=33, offs=9) -- 687(line=33, offs=16):
error(parsing): the keyword [in] is needed.
.../main.dats: 644(line=31, offs=8) -- 647(line=31, offs=11):
error(parsing): the syntactic entity [d0exp] is needed.
.../main.dats: 533(line=28, offs=1) -- 536(line=28, offs=4):
error(parsing): the token is discarded.
.../main.dats: 768(line=37, offs=3) -- 770(line=37, offs=5):
error(parsing): the token is discarded.
```
I miss-use `scase`? How to fix above error?
Best regards,
--
Kiwamu Okabe at METASEPI DESIGN
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/CAEvX6dnnggiVfZjpQTcYH6adzb%3D3Box6jM5aMk0sqyPRXgh32w%40mail.gmail.com.