From 6d9476beb7d9ab3a0209a5989b39867d18bb9dc5 Mon Sep 17 00:00:00 2001 From: Richardas Kuchinskas Date: Wed, 24 Jul 2024 20:43:10 +0300 Subject: [PATCH] 1000iq fix --- src/solver/solver.go | 8 ++-- src/tests/exprtype/exprtype_test.go | 72 +++++++++-------------------- src/types/lazy.go | 6 ++- src/types/map.go | 2 +- 4 files changed, 33 insertions(+), 55 deletions(-) diff --git a/src/solver/solver.go b/src/solver/solver.go index edb275bf7..db7a712d5 100644 --- a/src/solver/solver.go +++ b/src/solver/solver.go @@ -20,14 +20,16 @@ func mixedType() map[string]struct{} { } // resolveType resolves function calls, method calls and global variables. -// curStaticClass is current class name (if inside the class, otherwise "") +// +// curStaticClass is current class name (if inside the class, otherwise "") func resolveType(info *meta.Info, curStaticClass, typ string, visitedMap ResolverMap) (result map[string]struct{}) { r := resolver{info: info, visited: visitedMap} return r.resolveType(curStaticClass, typ) } // ResolveTypes resolves function calls, method calls and global variables. -// curStaticClass is current class name (if inside the class, otherwise "") +// +// curStaticClass is current class name (if inside the class, otherwise "") func ResolveTypes(info *meta.Info, curStaticClass string, m types.Map, visitedMap ResolverMap) map[string]struct{} { r := resolver{info: info, visited: visitedMap} return r.resolveTypes(curStaticClass, m) @@ -76,7 +78,7 @@ func (r *resolver) resolveTypeNoLateStaticBinding(class, typ string) map[string] return result } - if typ == "" || typ[0] >= types.WMax { + if types.IsAfterWMaxed(typ) { return identityType(typ) } diff --git a/src/tests/exprtype/exprtype_test.go b/src/tests/exprtype/exprtype_test.go index 16aaef9a7..47bd564b1 100644 --- a/src/tests/exprtype/exprtype_test.go +++ b/src/tests/exprtype/exprtype_test.go @@ -2201,72 +2201,44 @@ function f() { runExprTypeTest(t, &exprTypeTestParams{code: code}) } -func TestArrayTypesWithUnpack_Primitives(t *testing.T) { +func TestArrayTypesWithUnpackPrimitives(t *testing.T) { code := `= WMax +} + func FormatType(s string) (res string) { - if s == "" || s[0] >= WMax { + if IsAfterWMaxed(s) { return FormatSimpleType(s) } diff --git a/src/types/map.go b/src/types/map.go index c25c0487a..e7ba69579 100644 --- a/src/types/map.go +++ b/src/types/map.go @@ -411,7 +411,7 @@ func (m Map) LazyArrayElemType() Map { mm := make(map[string]struct{}, m.Len()) for typ := range m.m { // TODO: https://github.com/VKCOM/noverify/issues/1227 - if typ == "null" { + if IsAfterWMaxed(typ) { break }