Skip to content

Commit

Permalink
fixed unboxing from null for arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidanio committed Mar 13, 2024
1 parent 3ef4699 commit 7153438
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/tests/regression/issue1214_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package regression_test

import (
"testing"

"github.com/VKCOM/noverify/src/linttest"
)

func TestIssue1214(t *testing.T) {
linttest.SimpleNegativeTest(t, `<?php
declare(strict_types = 1);
function test() {
$special_items = null;
$_ = [...$special_items];
}`)
}
5 changes: 4 additions & 1 deletion src/types/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,10 @@ func (m Map) LazyArrayElemType() Map {

mm := make(map[string]struct{}, m.Len())
for typ := range m.m {
if typ == "null" {
break
}

if typ == "empty_array" {
// If the type contains only empty_array,
// then we resolve its element as mixed.
Expand All @@ -420,7 +424,6 @@ func (m Map) LazyArrayElemType() Map {
// is a more precise type.
continue
}

mm[UnwrapArrayOf(typ)] = struct{}{}
}
return Map{m: mm, flags: m.flags}
Expand Down

0 comments on commit 7153438

Please sign in to comment.