bootsnap 1.24.0 → 1.24.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9680e880d828e4c61704db75e793e97b4bcaa9142e37335b697d28a14c1d7f9c
4
- data.tar.gz: 876136914c8d89c771304fffc2d8587b3b15b0eb6abbf684ad5d4adb39b98550
3
+ metadata.gz: 24c756fe8c17824d00469a5e8e444e6ed9f2710566e623ea8dbd569deb425c83
4
+ data.tar.gz: aefe758480d38080ff1b0ffd45954dbe7aa992cab3b6f3e6cea7966c2af97696
5
5
  SHA512:
6
- metadata.gz: 84bd60feda93f48dfeb2c8149c72a72a619050eb163decf83bf14d78173a3aa52adff84dc6a22f7821ee7d1c937a0449f96686f6199c77e53ff990f123c30359
7
- data.tar.gz: 41d345dee52323ba80df2c8165bad4a4ea6c04780d8eb7e459a5e766973b797f68267ac63fbad38a3add47e59041aa8d7786ddb43b5ed0cfb7ac98743cd70ca5
6
+ metadata.gz: 614ff9e0eaac288fb4a890e3ca0926e720c06fdc68de3ce33d015d1ad477b4172126614c321fb1da1bb6e4c8539ba80c774b8f9a619c7475b0469c9001a0eca2
7
+ data.tar.gz: e85e9357079e541270b659f0b11c71b3e286099d590aaba4fc90ac1462a2bf916e5e7752fa87d5f6d760598e9a0ea3e66c6e99f55f3085345516e28a17fa4caa
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Unreleased
2
2
 
3
+ # 1.24.2
4
+
5
+ * Workaround two Ruby bugs in `RubyVM::InstructionSequence.compile_file`, that were causing
6
+ files to be loaded with the old Ruby parser instead of Prism, causing issues with some pattern matching syntax.
7
+ Ref: https://bugs.ruby-lang.org/issues/22023
8
+
9
+ # 1.24.1
10
+
11
+ * Fix encoding of Ruby source files loaded when `BOOTSNAP_READONLY` is set.
12
+ Files would incorectly be loaded in `ASCII-8BIT` causing literal strings outside
13
+ the pure ASCII range to have `ASCII-8BIT` encoding instead of `UTF-8`.
14
+ This bug was introduced in `1.24.0`.
15
+
3
16
  # 1.24.0
4
17
 
5
18
  * Added a hook API to customize Ruby compilation.
@@ -36,19 +36,47 @@ module Bootsnap
36
36
  true
37
37
  end
38
38
 
39
+ has_ruby_bug_22023 = if defined?(RubyVM::InstructionSequence) && RubyVM::InstructionSequence.respond_to?(:compile_file_prism)
40
+ begin
41
+ RubyVM::InstructionSequence.compile_file(File.expand_path("../ruby_bug_22023_canary.rb", __FILE__))
42
+ false
43
+ rescue SyntaxError
44
+ true
45
+ end
46
+ end
47
+
48
+ if has_ruby_bug_22023 && RUBY_DESCRIPTION.include?("+PRISM")
49
+ module PatchRubyBug22023
50
+ def compile_file(path, options = nil)
51
+ compile_file_prism(path, options)
52
+ end
53
+
54
+ has_ruby_bug_22023_bis = !RubyVM::InstructionSequence.compile_file_prism(
55
+ File.expand_path("../ruby_bug_22023_canary.rb", __FILE__),
56
+ {frozen_string_literal: true},
57
+ ).eval.frozen?
58
+
59
+ if has_ruby_bug_22023_bis
60
+ def compile_file_prism(path, options = nil)
61
+ compile_prism(::File.read(path), path, path, nil, options)
62
+ end
63
+ end
64
+ end
65
+ RubyVM::InstructionSequence.singleton_class.prepend(PatchRubyBug22023)
66
+ end
67
+
39
68
  if has_ruby_bug_18250
40
69
  def input_to_storage(_, path)
41
70
  iseq = RubyVM::InstructionSequence.compile_file(path, @compile_options)
42
-
43
- begin
44
- iseq.to_binary
45
- rescue TypeError
46
- UNCOMPILABLE # ruby bug #18250
47
- end
71
+ iseq.to_binary
72
+ rescue TypeError, SyntaxError # Ruby [Bug #18250] & [Bug #22023]
73
+ UNCOMPILABLE
48
74
  end
49
75
  else
50
76
  def input_to_storage(_, path)
51
77
  RubyVM::InstructionSequence.compile_file(path, @compile_options).to_binary
78
+ rescue SyntaxError # Ruby [Bug #22023]
79
+ UNCOMPILABLE
52
80
  end
53
81
  end
54
82
 
@@ -66,7 +94,13 @@ module Bootsnap
66
94
  end
67
95
 
68
96
  def input_to_output(source, path, _kwargs)
69
- RubyVM::InstructionSequence.compile(source, path, path, nil, @compile_options)
97
+ RubyVM::InstructionSequence.compile(
98
+ source.force_encoding(Encoding.default_external),
99
+ path,
100
+ path,
101
+ nil,
102
+ @compile_options,
103
+ )
70
104
  end
71
105
  end
72
106
 
@@ -0,0 +1,10 @@
1
+ # rubocop:disable Style/FrozenStringLiteralComment
2
+ def foo(bars)
3
+ case bars
4
+ in [one, "a" | "b" => two]
5
+ puts "#{one} - #{two}"
6
+ end
7
+ end
8
+
9
+ _ = "test"
10
+ # rubocop:enable Style/FrozenStringLiteralComment
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bootsnap
4
- VERSION = "1.24.0"
4
+ VERSION = "1.24.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootsnap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.24.0
4
+ version: 1.24.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Burke Libbey
@@ -44,6 +44,7 @@ files:
44
44
  - lib/bootsnap/cli/worker_pool.rb
45
45
  - lib/bootsnap/compile_cache.rb
46
46
  - lib/bootsnap/compile_cache/iseq.rb
47
+ - lib/bootsnap/compile_cache/ruby_bug_22023_canary.rb
47
48
  - lib/bootsnap/compile_cache/yaml.rb
48
49
  - lib/bootsnap/explicit_require.rb
49
50
  - lib/bootsnap/load_path_cache.rb