solargraph icon indicating copy to clipboard operation
solargraph copied to clipboard

Using solargraph, can popup documentation for Psych.safe_load, but not for Psych.safe_dump

Open rubin55 opened this issue 6 months ago • 3 comments

Using solargraph 0.54.5 with zed. Example code:

#!/usr/bin/env ruby
require 'psych'

Psych.safe_load('--- foo')
puts(Psych.safe_dump('foo'))
  • Hovering over Psych correctly shows the module documentation
  • Hovering over safe_load correctly shows the documentation for the save_load method
  • Hovering over safe_dump does nothing. Additionally, safe_dump does not show up in completion popups, even though the function exists (Running Ruby 3.4.4 on Arch Linux. using system-wide psych.rb in /usr/lib/ruby/3.4.0/psych.rb which is part of the ruby package on Arch Linux)

Why does solargraph act as if safe_dump does not exist?

rubin55 avatar May 27 '25 14:05 rubin55

Why does solargraph act as if safe_dump does not exist?

Looks like Ruby's RBS types don't include that method :(

https://github.com/ruby/rbs/blob/36e53a2a75f90356d2410c522da31a4171a8fbbe/stdlib/psych/0/psych.rbs#L46

We don't currently parse Ruby core/stdlib source, just gems - so if it's not in the RBS, solargraph doesn't currently pick it up. Even if we did, the Ruby source doesn't include type information, so getting this into the rbs repo would be the ideal fix.

apiology avatar May 27 '25 14:05 apiology

Alright, so should I file a bug on RBS? I'm not sure how the ruby ecosystem handles this normally..

rubin55 avatar May 27 '25 14:05 rubin55

That'd fix it for sure. rbs is a gem from this GitHub repo: https://github.com/ruby/rbs/blob/master/docs/CONTRIBUTING.md

apiology avatar May 27 '25 14:05 apiology