Skip to content

Commit b8dce15

Browse files
authored
Upgrade to Ruby 3.4.1 (#3003)
### Motivation Starting the new year always means the same thing: new rubies! Upgrade to Ruby 3.4.1. There were some tiny differences that I had to fix: 1. The output of hashes changed from the old rocket syntax to the new. We can't simply update the expectations because then tests will fail on <3.4 2. The locations of some syntax error diagnostics have changed. I switched to a hand written test to make it easy to account for different behaviours, but I kept the fixture so that non-raise expectations continue to run 3. The last one I'm unsure if it's a bug or an intentional change. Based on our document symbol test and implementation, it seems that in <3.4 `empty?` returns `true` if the contents of the string are just a line break. This doesn't seem to be the case anymore 4. Many default gems now became bundled gems. We now need to add `csv` and `base64` to the Jekyll bundle since the gem doesn't declare an explicit dependency on them, but they have been removed
1 parent 3ccc50d commit b8dce15

File tree

14 files changed

+93
-163
lines changed

14 files changed

+93
-163
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
fail-fast: false
4242
matrix:
4343
os: [ubuntu-latest, macos-latest, windows-latest]
44-
ruby: ["3.1", "3.2", "3.3"]
44+
ruby: ["3.1", "3.2", "3.3", "3.4"]
4545
runs-on: ${{ matrix.os }}
4646
timeout-minutes: 30
4747
name: Ruby ${{ matrix.ruby }} on ${{ matrix.os }}

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.4
1+
3.4.1

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,4 @@ DEPENDENCIES
146146
tapioca (~> 0.16)
147147

148148
BUNDLED WITH
149-
2.5.11
149+
2.6.2

jekyll/Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ gem "jekyll-feed", "~> 0.12"
99

1010
# Theme
1111
gem "just-the-docs", "~> 0.10.0"
12+
gem "csv"
13+
gem "base64"

jekyll/Gemfile.lock

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,28 @@ GEM
33
specs:
44
addressable (2.8.7)
55
public_suffix (>= 2.0.2, < 7.0)
6+
base64 (0.2.0)
67
bigdecimal (3.1.8)
78
colorator (1.1.0)
89
concurrent-ruby (1.3.4)
10+
csv (3.3.2)
911
em-websocket (0.5.3)
1012
eventmachine (>= 0.12.9)
1113
http_parser.rb (~> 0)
1214
eventmachine (1.2.7)
13-
ffi (1.17.0)
14-
ffi (1.17.0-aarch64-linux-gnu)
15-
ffi (1.17.0-aarch64-linux-musl)
16-
ffi (1.17.0-arm-linux-gnu)
17-
ffi (1.17.0-arm-linux-musl)
18-
ffi (1.17.0-arm64-darwin)
19-
ffi (1.17.0-x86-linux-gnu)
20-
ffi (1.17.0-x86-linux-musl)
21-
ffi (1.17.0-x86_64-darwin)
22-
ffi (1.17.0-x86_64-linux-gnu)
23-
ffi (1.17.0-x86_64-linux-musl)
15+
ffi (1.17.1)
16+
ffi (1.17.1-aarch64-linux-gnu)
17+
ffi (1.17.1-aarch64-linux-musl)
18+
ffi (1.17.1-arm-linux-gnu)
19+
ffi (1.17.1-arm-linux-musl)
20+
ffi (1.17.1-arm64-darwin)
21+
ffi (1.17.1-x86-linux-gnu)
22+
ffi (1.17.1-x86-linux-musl)
23+
ffi (1.17.1-x86_64-darwin)
24+
ffi (1.17.1-x86_64-linux-gnu)
25+
ffi (1.17.1-x86_64-linux-musl)
2426
forwardable-extended (2.6.0)
25-
google-protobuf (4.28.2)
26-
bigdecimal
27-
rake (>= 13)
28-
google-protobuf (4.28.2-aarch64-linux)
29-
bigdecimal
30-
rake (>= 13)
31-
google-protobuf (4.28.2-arm64-darwin)
32-
bigdecimal
33-
rake (>= 13)
34-
google-protobuf (4.28.2-x86-linux)
35-
bigdecimal
36-
rake (>= 13)
37-
google-protobuf (4.28.2-x86_64-darwin)
38-
bigdecimal
39-
rake (>= 13)
40-
google-protobuf (4.28.2-x86_64-linux)
27+
google-protobuf (4.29.2)
4128
bigdecimal
4229
rake (>= 13)
4330
http_parser.rb (0.8.0)
@@ -173,6 +160,8 @@ PLATFORMS
173160
x86_64-linux-musl
174161

175162
DEPENDENCIES
163+
base64
164+
csv
176165
jekyll (~> 4.3.4)
177166
jekyll-feed (~> 0.12)
178167
just-the-docs (~> 0.10.0)

lib/ruby_lsp/listeners/document_symbol.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def on_alias_method_node_enter(node)
340340
).returns(Interface::DocumentSymbol)
341341
end
342342
def create_document_symbol(name:, kind:, range_location:, selection_range_location:)
343-
name = "<blank>" if name.empty?
343+
name = "<blank>" if name.strip.empty?
344344
symbol = Interface::DocumentSymbol.new(
345345
name: name,
346346
kind: kind,

test/expectations/diagnostics/syntax_diagnostics.exp.json

Lines changed: 0 additions & 110 deletions
This file was deleted.

test/integration_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def test_composed_bundle_includes_debug
156156
"bundle exec ruby -e 'require \"debug\"'",
157157
)
158158
end
159-
assert_empty(stderr)
159+
refute_match(/cannot load such file/, stderr)
160160
end
161161
end
162162
end

test/requests/diagnostics_test.rb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,41 @@ def run_diagnostic(uri, document)
105105
diagnostics = T.must(RubyLsp::Requests::Diagnostics.new(@global_state, document).perform)
106106
assert(diagnostics.find { |d| d.message == "Hello from custom formatter" })
107107
end
108+
109+
def test_ambiguous_syntax_warnings
110+
document = RubyLsp::RubyDocument.new(source: <<~RUBY.chomp, version: 1, uri: URI("file:///fake/file.rb"))
111+
b +a
112+
b -a
113+
b *a
114+
b /a/
115+
RUBY
116+
117+
diagnostics = T.must(RubyLsp::Requests::Diagnostics.new(@global_state, document).perform)
118+
assert_match("ambiguous first argument", T.must(diagnostics[0]).message)
119+
assert_match("ambiguous first argument", T.must(diagnostics[1]).message)
120+
assert_match("ambiguous `*`", T.must(diagnostics[2]).message)
121+
assert_match("ambiguous `/`", T.must(diagnostics[3]).message)
122+
end
123+
124+
def test_END_inside_method_definition_warning
125+
document = RubyLsp::RubyDocument.new(source: <<~RUBY.chomp, version: 1, uri: URI("file:///fake/file.rb"))
126+
def m; END{}; end
127+
RUBY
128+
129+
diagnostics = T.must(RubyLsp::Requests::Diagnostics.new(@global_state, document).perform)
130+
assert_equal("END in method; use at_exit", T.must(diagnostics[0]).message)
131+
end
132+
133+
def test_syntax_error_diagnostic
134+
document = RubyLsp::RubyDocument.new(source: <<~RUBY.chomp, version: 1, uri: URI("file:///fake/file.rb"))
135+
def foo
136+
RUBY
137+
138+
diagnostics = T.must(RubyLsp::Requests::Diagnostics.new(@global_state, document).perform)
139+
assert_equal("expected a delimiter to close the parameters", T.must(diagnostics[0]).message)
140+
assert_equal(
141+
"unexpected end-of-input, assuming it is closing the parent top level context",
142+
T.must(diagnostics[1]).message,
143+
)
144+
end
108145
end

test/ruby_document_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,8 @@ class Foo
784784
document.locate_node({ line: 3, character: 2 })
785785
end
786786

787-
assert_equal(<<~MESSAGE.chomp, error.message)
788-
Requested position: {:line=>3, :character=>2}
787+
assert_match(/Requested position: {(:)?line[\s:=>]+3, (:)?character[\s:=>]+2}/, error.message)
788+
assert_match(<<~MESSAGE.chomp, error.message)
789789
Source:
790790
791791
class Foo

0 commit comments

Comments
 (0)