Hi all,

today I spotted an error in my code. Here is the snippet:
```
                val millis = $BS.pack( msecs_i64 + ($UN.cast{int64} msecs)
) // + $UN.cast{int32} msecs )
                val env = ( hws, millis)
                val () = list_vt_foreach_funenv0< ( $BS.BytestringNSH1,
$BS.BytestringNSH1) ><($BS.BytestringNSH1,$BS.BytestringNSH1)>{void}( () |
kvs, env, print_json) where {
                  fn
                    print_json
                    ( pf: !void
                    | x: &(@($BS.BytestringNSH1, $BS.BytestringNSH1))
                    , env: !($BS.BytestringNSH1, $BS.BytestringNSH1)
                    ): void = {
                      val (hws, millis) = env
                      val bs = $BS.pack "{ \"tenant\": \"demo\",
\"buildingId\": \"demo\", "
                        + $BS.pack "\"metadata\": { \"name\": \"" +! x.0 +
$BS.pack "\"}, "
                        + $BS.pack "\"value\": " +! x.1 + $BS.pack ", "
                        + $BS.pack "\"timestamp\": " +! millis + $BS.pack
", "
                        + $BS.pack "\"deviceId\": \"" +! hws + $BS.pack "\""
                        + $BS.pack "}"
                      val () = $BS.printlnC( bs)
                      prval () = env := (hws, millis)
                    }
                }
*                val (hws1, _) = env (* here I can just ignore the
'millis'  and cause a memory leak *)*
                prval () = hws := hws1
                val () = list_vt_freelin_fun<@($BS.BytestringNSH1,
$BS.BytestringNSH1)> (kvs, cleaner) where {
                  fn cleaner( x: &($BS.BytestringNSH1, $BS.BytestringNSH1)
>> ($BS.BytestringNSH1, $BS.BytestringNSH1)?):void = {
                    val () = $BS.free x.0
                    val () = $BS.free x.1
                  }
                }
                val () = $BS.free( time)
                val () = $BS.free( rawpayload)
                val () = $BS.free( hws)
```
and the compiler hasn't bite my hands with this: it has typechecked and
compiled this code without issues. Only valgrind had.
And here is the correct snippet, which is compiling without issues as well.

```
                val millis = $BS.pack( msecs_i64 + ($UN.cast{int64} msecs)
) // + $UN.cast{int32} msecs )
                val env = ( hws, millis)
                val () = list_vt_foreach_funenv0< ( $BS.BytestringNSH1,
$BS.BytestringNSH1) ><($BS.BytestringNSH1,$BS.BytestringNSH1)>{void}( () |
kvs, env, print_json) where {
                  fn
                    print_json
                    ( pf: !void
                    | x: &(@($BS.BytestringNSH1, $BS.BytestringNSH1))
                    , env: !($BS.BytestringNSH1, $BS.BytestringNSH1)
                    ): void = {
                      val (hws, millis) = env
                      val bs = $BS.pack "{ \"tenant\": \"demo\",
\"buildingId\": \"demo\", "
                        + $BS.pack "\"metadata\": { \"name\": \"" +! x.0 +
$BS.pack "\"}, "
                        + $BS.pack "\"value\": " +! x.1 + $BS.pack ", "
                        + $BS.pack "\"timestamp\": " +! millis + $BS.pack
", "
                        + $BS.pack "\"deviceId\": \"" +! hws + $BS.pack "\""
                        + $BS.pack "}"
                      val () = $BS.printlnC( bs)
                      prval () = env := (hws, millis)
                    }
                }
*                val (hws1, millis1) = env*
                prval () = hws := hws1
*                prval () = millis := millis1*
                val () = list_vt_freelin_fun<@($BS.BytestringNSH1,
$BS.BytestringNSH1)> (kvs, cleaner) where {
                  fn cleaner( x: &($BS.BytestringNSH1, $BS.BytestringNSH1)
>> ($BS.BytestringNSH1, $BS.BytestringNSH1)?):void = {
                    val () = $BS.free x.0
                    val () = $BS.free x.1
                  }
                }
                val () = $BS.free( time)
                val () = $BS.free( rawpayload)
                val () = $BS.free( hws)
*                val () = $BS.free( millis)*
```

So is it expected to be able to just ignore the datavtype?

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAHjn2KxTNxLXSnX2nM%2BpCNOqZFsH%2BHrUPN9xRQ_JxiezoG8zFQ%40mail.gmail.com.

Reply via email to