Null-safe assertion on a Array fails in Kotlin/JS

The is the test case -

Note the use of null-assertion (children!!) which is not required. However, changing this to children? causes the test to fail

TypeError: Cannot read properties of undefined (reading ‘length’)

If you look at line which causes the error

   var $receiver_0 = first$result;
    var tmp$_1, tmp$_2;
    if ((tmp$_1 = $receiver_0.children) != null) {
      var tmp$_3;
      for (tmp$_3 = 0; tmp$_3 !== tmp$_1.length; ++tmp$_3) {
        var element_0 = tmp$_1[tmp$_3];
    var $receiver_1 = tmp$_2;
    var first$result_0;
    first$break: do {
      var tmp$_4;
      for (tmp$_4 = 0; tmp$_4 !== $receiver_1.length; ++tmp$_4) { // This line

$receiver_1 is null (because tmp$_2 is null which is never assigned to)

The same test on JVM target works fine -

Reproducible both on 1.6.21 and 1.7.10