Skip to content

Errors when opening a Dry::Validation::Contract #12

Description

@timriley

I'm trying ruby-lsp-hanami in https://github.com/decafsucks/decafsucks using Zed, and when I open slices/main/reviews/contract.rb in a tab, I get a slew of errors show up in the LSP logs:

Determined that document should be indexed: file:///Users/tim/Source/decafsucks/decafsucks/slices/main/reviews/contract.rb
Error processing textDocument/definition: /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'block in Prism::Dispatcher::DispatchOnce#visit_symbol_node': undefined method 'on_symbol_node_enter' for an instance of RubyLsp::Hanami::Definition (NoMethodError)

        listeners[:on_symbol_node_enter]&.each { |listener| listener.on_symbol_node_enter(node) }
                                                                    ^^^^^^^^^^^^^^^^^^^^^
Did you mean?  on_string_node_enter
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'Array#each'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'Prism::Dispatcher::DispatchOnce#visit_symbol_node'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/node.rb:18472:in 'Prism::SymbolNode#accept'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:83:in 'Prism::Dispatcher#dispatch_once'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/requests/definition.rb:96:in 'RubyLsp::Requests::Definition#perform'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/server.rb:1008:in 'RubyLsp::Server#text_document_definition'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/server.rb:72:in 'RubyLsp::Server#process_message'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/base_server.rb:179:in 'RubyLsp::BaseServer#handle_incoming_message'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/base_server.rb:157:in 'block in RubyLsp::BaseServer#new_worker'
Error processing textDocument/definition: /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'block in Prism::Dispatcher::DispatchOnce#visit_symbol_node': undefined method 'on_symbol_node_enter' for an instance of RubyLsp::Hanami::Definition (NoMethodError)

        listeners[:on_symbol_node_enter]&.each { |listener| listener.on_symbol_node_enter(node) }
                                                                    ^^^^^^^^^^^^^^^^^^^^^
Did you mean?  on_string_node_enter
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'Array#each'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'Prism::Dispatcher::DispatchOnce#visit_symbol_node'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/node.rb:18472:in 'Prism::SymbolNode#accept'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:83:in 'Prism::Dispatcher#dispatch_once'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/requests/definition.rb:96:in 'RubyLsp::Requests::Definition#perform'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/server.rb:1008:in 'RubyLsp::Server#text_document_definition'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/server.rb:72:in 'RubyLsp::Server#process_message'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/base_server.rb:179:in 'RubyLsp::BaseServer#handle_incoming_message'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/base_server.rb:157:in 'block in RubyLsp::BaseServer#new_worker'
Error processing textDocument/definition: /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'block in Prism::Dispatcher::DispatchOnce#visit_symbol_node': undefined method 'on_symbol_node_enter' for an instance of RubyLsp::Hanami::Definition (NoMethodError)

        listeners[:on_symbol_node_enter]&.each { |listener| listener.on_symbol_node_enter(node) }
                                                                    ^^^^^^^^^^^^^^^^^^^^^
Did you mean?  on_string_node_enter
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'Array#each'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'Prism::Dispatcher::DispatchOnce#visit_symbol_node'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/node.rb:18472:in 'Prism::SymbolNode#accept'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:83:in 'Prism::Dispatcher#dispatch_once'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/requests/definition.rb:96:in 'RubyLsp::Requests::Definition#perform'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/server.rb:1008:in 'RubyLsp::Server#text_document_definition'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/server.rb:72:in 'RubyLsp::Server#process_message'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/base_server.rb:179:in 'RubyLsp::BaseServer#handle_incoming_message'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/base_server.rb:157:in 'block in RubyLsp::BaseServer#new_worker'
Error processing textDocument/definition: /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'block in Prism::Dispatcher::DispatchOnce#visit_symbol_node': undefined method 'on_symbol_node_enter' for an instance of RubyLsp::Hanami::Definition (NoMethodError)

        listeners[:on_symbol_node_enter]&.each { |listener| listener.on_symbol_node_enter(node) }
                                                                    ^^^^^^^^^^^^^^^^^^^^^
Did you mean?  on_string_node_enter
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'Array#each'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'Prism::Dispatcher::DispatchOnce#visit_symbol_node'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/node.rb:18472:in 'Prism::SymbolNode#accept'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:83:in 'Prism::Dispatcher#dispatch_once'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/requests/definition.rb:96:in 'RubyLsp::Requests::Definition#perform'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/server.rb:1008:in 'RubyLsp::Server#text_document_definition'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/server.rb:72:in 'RubyLsp::Server#process_message'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/base_server.rb:179:in 'RubyLsp::BaseServer#handle_incoming_message'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/base_server.rb:157:in 'block in RubyLsp::BaseServer#new_worker'
Error processing textDocument/definition: /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'block in Prism::Dispatcher::DispatchOnce#visit_symbol_node': undefined method 'on_symbol_node_enter' for an instance of RubyLsp::Hanami::Definition (NoMethodError)

        listeners[:on_symbol_node_enter]&.each { |listener| listener.on_symbol_node_enter(node) }
                                                                    ^^^^^^^^^^^^^^^^^^^^^
Did you mean?  on_string_node_enter
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'Array#each'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'Prism::Dispatcher::DispatchOnce#visit_symbol_node'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/node.rb:18472:in 'Prism::SymbolNode#accept'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:83:in 'Prism::Dispatcher#dispatch_once'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/requests/definition.rb:96:in 'RubyLsp::Requests::Definition#perform'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/server.rb:1008:in 'RubyLsp::Server#text_document_definition'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/server.rb:72:in 'RubyLsp::Server#process_message'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/base_server.rb:179:in 'RubyLsp::BaseServer#handle_incoming_message'
	from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/base_server.rb:157:in 'block in RubyLsp::BaseServer#new_worker'

Here's the contents of that file:

# frozen_string_literal: true

require "dry/validation"

module Main
  module Reviews
    class Contract < Dry::Validation::Contract
      params do
        optional(:cafe_name).filled(:string)
        optional(:cafe_address).filled(:string)
        required(:rating).filled(:integer, gteq?: 1, lteq?: 10)
        required(:body).filled(:string)
      end
    end
  end
end

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions