solargraph 0.47.1 → 0.47.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d697adb07ecb0f68c08da0001decead501d9c755bf79b3870c0e3f67c062d6c
4
- data.tar.gz: 191141aee5b75aa20a514bbc807df5c058823094afa99d9948bada9067c3eb8b
3
+ metadata.gz: 9d35030ae56f6aaff108a24e4fb06713f911ba4366feb2223b24ad0ea4568522
4
+ data.tar.gz: a9eeaee16171bc762922ac55d10c61d53bcfe6ef1df0b20623c81e0978a80c7d
5
5
  SHA512:
6
- metadata.gz: fa47406469782b55edc3f75d6a4474d6730153333a40ac76092ca0586a7935f9ad36b44dfb641df35b48317c0e5fffb6d722dbe0df88833130da534c33ae80b6
7
- data.tar.gz: 5fb3c3e20abaa8b90375213601ec354ef936bfb7cc2f49fba44f6af3254e864ae38beaf6668186931a33fcd72d587fe5a29a67122cb3a65b2d85dd6deba6c147
6
+ metadata.gz: 0b13ae6284def50f72c9aaed3cad6f89e879306dc8421b1c13f622e18181e6d9aaecf4f57ffa56601a00c92066557bb798d3e8ee6a397920ff0072f909e05463
7
+ data.tar.gz: 9a0366309ebe9a4a784c2933a8452e2084c376ff9aa3cd6c3bf555f4d6ce046f11245679c688bef43c6c1e67d94b70afb4250149c9b01b80fc525b80a80b6486
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.47.2 - September 30, 2022
2
+ - Fix complex type inference (#578)
3
+ - Off-by-one diagnostic (#595)
4
+
1
5
  ## 0.47.1 - September 27, 2022
2
6
  - Remove debug code from release (#600)
3
7
 
@@ -74,6 +74,10 @@ module Solargraph
74
74
  @items.all? &block
75
75
  end
76
76
 
77
+ def any? &block
78
+ @items.any? &block
79
+ end
80
+
77
81
  def selfy?
78
82
  @items.any?(&:selfy?)
79
83
  end
@@ -89,7 +89,7 @@ module Solargraph
89
89
  Position.new(off['location']['start_line'], 0)
90
90
  else
91
91
  Position.new(
92
- off['location']['start_line'] - 1, off['location']['last_column']
92
+ off['location']['start_line'] - 1, off['location']['last_column'] - 1
93
93
  )
94
94
  end
95
95
  end
@@ -61,6 +61,19 @@ module Solargraph
61
61
  false
62
62
  end
63
63
 
64
+ # @param api_map [ApiMap]
65
+ # @param inferred [ComplexType]
66
+ # @param expected [ComplexType]
67
+ # @return [Boolean]
68
+ def all_types_match? api_map, inferred, expected
69
+ return duck_types_match?(api_map, expected, inferred) if expected.duck_type?
70
+ inferred.each do |inf|
71
+ next if inf.duck_type?
72
+ return false unless expected.any? { |exp| exp == inf || either_way?(api_map, inf, exp) }
73
+ end
74
+ true
75
+ end
76
+
64
77
  # @param api_map [ApiMap]
65
78
  # @param expected [ComplexType]
66
79
  # @param inferred [ComplexType]
@@ -105,7 +105,7 @@ module Solargraph
105
105
  result.push Problem.new(pin.location, "#{pin.path} return type could not be inferred", pin: pin)
106
106
  end
107
107
  else
108
- unless (rules.rank > 1 ? types_match?(api_map, declared, inferred) : any_types_match?(api_map, declared, inferred))
108
+ unless (rules.rank > 1 ? all_types_match?(api_map, inferred, declared) : any_types_match?(api_map, declared, inferred))
109
109
  result.push Problem.new(pin.location, "Declared return type #{declared} does not match inferred type #{inferred} for #{pin.path}", pin: pin)
110
110
  end
111
111
  end
@@ -177,7 +177,7 @@ module Solargraph
177
177
  result.push Problem.new(pin.location, "Variable type could not be inferred for #{pin.name}", pin: pin)
178
178
  end
179
179
  else
180
- unless (rules.rank > 1 ? types_match?(api_map, declared, inferred) : any_types_match?(api_map, declared, inferred))
180
+ unless any_types_match?(api_map, declared, inferred)
181
181
  result.push Problem.new(pin.location, "Declared type #{declared} does not match inferred type #{inferred} for variable #{pin.name}", pin: pin)
182
182
  end
183
183
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Solargraph
4
- VERSION = '0.47.1'
4
+ VERSION = '0.47.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solargraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.47.1
4
+ version: 0.47.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-27 00:00:00.000000000 Z
11
+ date: 2022-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backport