Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support shorthand hash for ruby 3.1 #567

Merged
merged 2 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PATH
language_server-protocol (>= 3.15, < 4.0)
listen (~> 3.0)
parallel (>= 1.0.0)
parser (>= 3.0)
parser (>= 3.1)
rainbow (>= 2.2.2, < 4.0)
rbs (>= 2.3.2)
terminal-table (>= 2, < 4)
Expand Down
2 changes: 1 addition & 1 deletion lib/steep.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "steep/version"

require "pathname"
require "parser/ruby30"
require "parser/ruby31"
require "active_support"
require "active_support/core_ext/object/try"
require "active_support/core_ext/string/inflections"
Expand Down
2 changes: 1 addition & 1 deletion lib/steep/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def string_value(token)
end

def self.new_parser
::Parser::Ruby30.new(Builder.new).tap do |parser|
::Parser::Ruby31.new(Builder.new).tap do |parser|
parser.diagnostics.all_errors_are_fatal = true
parser.diagnostics.ignore_warnings = true
end
Expand Down
2 changes: 1 addition & 1 deletion steep.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = '>= 2.6.0'

spec.add_runtime_dependency "parser", ">= 3.0"
spec.add_runtime_dependency "parser", ">= 3.1"
spec.add_runtime_dependency "activesupport", ">= 5.1"
spec.add_runtime_dependency "rainbow", ">= 2.2.2", "< 4.0"
spec.add_runtime_dependency "listen", "~> 3.0"
Expand Down
2 changes: 1 addition & 1 deletion test/lsp_formatter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class LSPFormatterTest < Minitest::Test
LSPFormatter = Diagnostic::LSPFormatter

def node
::Parser::Ruby30.parse("1+2")
::Parser::Ruby31.parse("1+2")
end

def test_severity_for
Expand Down
17 changes: 17 additions & 0 deletions test/type_construction_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8873,4 +8873,21 @@ def bar(*args, name:)
end
end
end

def test_ruby31_shorthand_hash
with_checker do |checker|
source = parse_ruby(<<RUBY)
x = 1
{ x: }
RUBY

with_standard_construction(checker, source) do |construction, typing|
type, _ = construction.synthesize(source.node)

assert_equal parse_type("::Hash[::Symbol, ::Integer]"), type

assert_no_error typing
end
end
end
end