Skip to content

Solargraph fails to determine hash value types (IntelliSense) #961

Open
@SnowSzn

Description

@SnowSzn

Hi,

Recently I realized that hash types cannot be determined when accesing a value, even if the hash is documented with the @type YARD tag.

No errors are raised but, as a result, Solargraph fails to show information like methods and autocomplete when the intellisense contextual menu is used.

Image

Take the example below:

class Foo
  #
  # Returns foo
  #
  def foo
    "foo"
  end
end

# @type [Hash<Integer, String>]
hash_a = {1 => "a", 2 => "b", 3 => "c"}
# @type [Hash<Integer, Foo>]
hash_b = {1 => Foo.new, 2 => Foo.new, 3 => Foo.new}

value_a = hash_a[1]
value_b = hash_b[1]
p value_a
p value_b

Unless I'm wrong I remember using the YARD tag @type for hashes and it worked in previous versions

Maybe worth to mention that arrays do not have this problem, the type is properly resolved and everything works as expected.

I'm using the latest solargraph version 0.55.0 and VSCode version 1.100.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions