typeprof 0.21.8 → 0.21.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71c74382cb8602ed9c902218ec5066d20865cc8040e5af6737e8d8a0d19beca9
4
- data.tar.gz: 2646a63cd334443a8dc716f99a5828fac960afdf80f8a0f8c8b5f289e6fb957d
3
+ metadata.gz: '06598fbcfb3ce3394271ccc6f97304d4cc902f57eb581c3341865a6a17b9ec27'
4
+ data.tar.gz: f9359077192046c0dc45884b64af37ddd06586866ad8231d292d5e7d013861ec
5
5
  SHA512:
6
- metadata.gz: 9c0ca22252a4804152efafafb63c9c8d1d1fb2e796a9d17251f1634dc1393c7fcaac7f924d4a341a0699c5113c3fea8bb03714ceb287ded60bc7057cac7a640c
7
- data.tar.gz: 899c481fc8a4a05787ab0e66064220b33b17f8f1f0f045b9a1d05d4ebdae1ea4cd62cfe552342588b5a2834491638303be5a2e05c4b00d99713fe4693a6c557a
6
+ metadata.gz: 3c72b7cf70f321c75b42f2addacfa2a27f9cfa3f5c010ae0b430e3385e3d3befaf749a190d57d9228976afa48e56d91d8a8abab2823c69401c17dd8523ee2697
7
+ data.tar.gz: 1cfc46a0c0ac7bd5e7ec96c6a8f9e24c4854daa1ec1c830a0eb5af0348d2271865ca65400dca12cd892b6e33fd9929fae41d379064a1dceabc2d8dbf96292243
@@ -24,7 +24,7 @@ jobs:
24
24
  ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
25
25
  runs-on: ubuntu-latest
26
26
  steps:
27
- - uses: actions/checkout@v3
27
+ - uses: actions/checkout@v4
28
28
  - name: Set up Ruby
29
29
  uses: ruby/setup-ruby@v1
30
30
  with:
data/Gemfile.lock CHANGED
@@ -1,17 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- typeprof (0.21.8)
4
+ typeprof (0.21.10)
5
5
  rbs (>= 1.8.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ abbrev (0.1.2)
10
11
  coverage-helpers (1.0.0)
11
12
  docile (1.4.0)
12
13
  power_assert (2.0.1)
13
14
  rake (13.0.1)
14
- rbs (3.2.0)
15
+ rbs (3.4.3)
16
+ abbrev
15
17
  simplecov (0.21.2)
16
18
  docile (~> 1.1)
17
19
  simplecov-html (~> 0.11)
@@ -2137,7 +2137,7 @@ module TypeProf
2137
2137
  end
2138
2138
  end
2139
2139
  return
2140
- when :concatarray
2140
+ when :concatarray, :concattoarray
2141
2141
  env, (ary1, ary2) = env.pop(2)
2142
2142
  if ary1.is_a?(Type::Local) && ary1.kind == Type::Array
2143
2143
  elems1 = get_container_elem_types(env, ep, ary1.id)
@@ -2156,6 +2156,20 @@ module TypeProf
2156
2156
  env, ty = localize_type(ty, env, ep)
2157
2157
  env = env.push(ty)
2158
2158
  end
2159
+ when :pushtoarray
2160
+ num, = operands
2161
+ env, (ary, ty, *tys) = env.pop(num + 1)
2162
+ if ary.is_a?(Type::Local) && ary.kind == Type::Array
2163
+ tys.each {|ty0| ty = ty.union(ty0) }
2164
+ elems = get_container_elem_types(env, ep, ary.id)
2165
+ elems = Type::Array::Elements.new([], elems.squash.union(ty))
2166
+ env = update_container_elem_types(env, ep, ary.id, ary.base_type) { elems }
2167
+ env = env.push(ary)
2168
+ else
2169
+ elems = Type::Array::Elements.new([], Type.any)
2170
+ env = update_container_elem_types(env, ep, ary.id, ary.base_type) { elems }
2171
+ env = env.push(ary)
2172
+ end
2159
2173
 
2160
2174
  when :checktype
2161
2175
  kind, = operands
@@ -32,6 +32,8 @@ TypeProf::INSN_TABLE = {:nop=>[],
32
32
  :duphash=>["VALUE"],
33
33
  :expandarray=>["rb_num_t", "rb_num_t"],
34
34
  :concatarray=>[],
35
+ :concattoarray=>[],
36
+ :pushtoarray=>["rb_num_t"],
35
37
  :splatarray=>["VALUE"],
36
38
  :newhash=>["rb_num_t"],
37
39
  :newrange=>["rb_num_t"],
data/lib/typeprof/iseq.rb CHANGED
@@ -276,7 +276,7 @@ module TypeProf
276
276
  misc[:def_node_id] = node_id
277
277
  end
278
278
  end
279
- ninsns << Insn.new(insn, operands, lineno, code_range, nil)
279
+ ninsns << i = Insn.new(insn, operands, lineno, code_range, nil)
280
280
  else
281
281
  raise "unknown iseq entry: #{ e }"
282
282
  end
@@ -840,10 +840,15 @@ module TypeProf
840
840
  sp -= 1
841
841
  return nil if sp <= 0
842
842
  sp += num + (splat ? 1 : 0)
843
- when :concatarray
843
+ when :concatarray, :concattoarray
844
844
  sp -= 2
845
845
  return nil if sp <= 0
846
846
  sp += 1
847
+ when :pushtoarray
848
+ num, = operands
849
+ sp -= num + 1
850
+ return nil if sp <= 0
851
+ sp += 1
847
852
  when :checktype
848
853
  sp -= 1
849
854
  return nil if sp <= 0
data/lib/typeprof/type.rb CHANGED
@@ -734,14 +734,19 @@ module TypeProf
734
734
 
735
735
  def []=(k_ty, v_ty)
736
736
  k_ty.each_child_global do |k_ty|
737
- # This is a temporal hack to mitigate type explosion
738
- k_ty = Type.any if k_ty.is_a?(Type::Array)
739
- k_ty = Type.any if k_ty.is_a?(Type::Hash)
740
-
741
- if @map_tys[k_ty]
742
- @map_tys[k_ty] = @map_tys[k_ty].union(v_ty)
737
+ if k_ty.is_a?(Type::Union)
738
+ # Flatten recursive union
739
+ self[k_ty] = v_ty
743
740
  else
744
- @map_tys[k_ty] = v_ty
741
+ # This is a temporal hack to mitigate type explosion
742
+ k_ty = Type.any if k_ty.is_a?(Type::Array)
743
+ k_ty = Type.any if k_ty.is_a?(Type::Hash)
744
+
745
+ if @map_tys[k_ty]
746
+ @map_tys[k_ty] = @map_tys[k_ty].union(v_ty)
747
+ else
748
+ @map_tys[k_ty] = v_ty
749
+ end
745
750
  end
746
751
  end
747
752
  end
@@ -1,3 +1,3 @@
1
1
  module TypeProf
2
- VERSION = "0.21.8"
2
+ VERSION = "0.21.10"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typeprof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.8
4
+ version: 0.21.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke Endoh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-28 00:00:00.000000000 Z
11
+ date: 2024-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbs
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  requirements: []
92
- rubygems_version: 3.5.0.dev
92
+ rubygems_version: 3.6.0.dev
93
93
  signing_key:
94
94
  specification_version: 4
95
95
  summary: TypeProf is a type analysis tool for Ruby code based on abstract interpretation