Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ jobs:

- name: Create a release on GitHub
run: |
RELEASE_TAG=$(echo v${{ env.RUBY_VERSION }} | sed 's/\./_/g')
RELEASE_TAG=$(ruby tool/ruby-version.rb tag "${{ env.RUBY_VERSION }}")
echo $RELEASE_TAG
PREVIOUS_RELEASE_TAG=$(echo $RELEASE_TAG | awk 'BEGIN {FS="_"; OFS="_"}{ $NF=$NF-1; print }')
PREVIOUS_RELEASE_TAG=$(ruby tool/ruby-version.rb previous-tag "${{ env.RUBY_VERSION }}")
echo $PREVIOUS_RELEASE_TAG
tool/gen-github-release.rb $PREVIOUS_RELEASE_TAG $RELEASE_TAG --no-dry-run
env:
Expand Down
7 changes: 5 additions & 2 deletions include/ruby/win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ struct ifaddrs {
#endif

extern void rb_w32_sysinit(int *, char ***);
extern DWORD rb_w32_osid(void);
extern int flock(int fd, int oper);
extern int rb_w32_io_cancelable_p(int);
extern int rb_w32_is_socket(int);
Expand Down Expand Up @@ -306,7 +305,11 @@ extern void rb_w32_free_environ(char **);
extern int rb_w32_map_errno(DWORD);
extern const char *WSAAPI rb_w32_inet_ntop(int,const void *,char *,size_t);
extern int WSAAPI rb_w32_inet_pton(int,const char *,void *);
extern DWORD rb_w32_osver(void);

RBIMPL_ATTR_DEPRECATED(("as Windows 9x is not supported already"))
static inline DWORD rb_w32_osid(void) {return VER_PLATFORM_WIN32_NT;}
RBIMPL_ATTR_DEPRECATED(("by Windows Version Helper APIs"))
extern DWORD rb_w32_osver(void);

extern int rb_w32_uchown(const char *, int, int);
extern int rb_w32_ulink(const char *, const char *);
Expand Down
4 changes: 4 additions & 0 deletions proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,10 @@ bind_local_variable_defined_p(VALUE bindval, VALUE sym)
const rb_env_t *env;

if (!lid) return Qfalse;
if (rb_numparam_id_p(lid)) {
rb_name_err_raise("numbered parameter '%1$s' is not a local variable",
bindval, ID2SYM(lid));
}

GetBindingPtr(bindval, bind);
env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block));
Expand Down
14 changes: 14 additions & 0 deletions test/ruby/test_proc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1659,29 +1659,35 @@ def test_numparam_is_not_local_variables
assert_equal([], binding.local_variables)
assert_raise(NameError) { binding.local_variable_get(:_9) }
assert_raise(NameError) { binding.local_variable_set(:_9, 1) }
assert_raise(NameError) { binding.local_variable_defined?(:_9) }
"bar".tap do
assert_equal([], binding.local_variables)
assert_raise(NameError) { binding.local_variable_get(:_9) }
assert_raise(NameError) { binding.local_variable_set(:_9, 1) }
assert_raise(NameError) { binding.local_variable_defined?(:_9) }
end
assert_equal([], binding.local_variables)
assert_raise(NameError) { binding.local_variable_get(:_9) }
assert_raise(NameError) { binding.local_variable_set(:_9, 1) }
assert_raise(NameError) { binding.local_variable_defined?(:_9) }
end

"foo".tap do
assert_equal([], binding.local_variables)
assert_raise(NameError) { binding.local_variable_get(:_9) }
assert_raise(NameError) { binding.local_variable_set(:_9, 1) }
assert_raise(NameError) { binding.local_variable_defined?(:_9) }
"bar".tap do
_9 and flunk
assert_equal([], binding.local_variables)
assert_raise(NameError) { binding.local_variable_get(:_9) }
assert_raise(NameError) { binding.local_variable_set(:_9, 1) }
assert_raise(NameError) { binding.local_variable_defined?(:_9) }
end
assert_equal([], binding.local_variables)
assert_raise(NameError) { binding.local_variable_get(:_9) }
assert_raise(NameError) { binding.local_variable_set(:_9, 1) }
assert_raise(NameError) { binding.local_variable_defined?(:_9) }
end
end

Expand All @@ -1690,31 +1696,39 @@ def test_it_is_not_local_variable
it
assert_equal([], binding.local_variables)
assert_raise(NameError) { binding.local_variable_get(:it) }
assert_equal(false, binding.local_variable_defined?(:it))
"bar".tap do
assert_equal([], binding.local_variables)
assert_raise(NameError) { binding.local_variable_get(:it) }
assert_equal(false, binding.local_variable_defined?(:it))
end
assert_equal([], binding.local_variables)
assert_raise(NameError) { binding.local_variable_get(:it) }
assert_equal(false, binding.local_variable_defined?(:it))
"bar".tap do
it
assert_equal([], binding.local_variables)
assert_raise(NameError) { binding.local_variable_get(:it) }
assert_equal(false, binding.local_variable_defined?(:it))
end
assert_equal([], binding.local_variables)
assert_raise(NameError) { binding.local_variable_get(:it) }
assert_equal(false, binding.local_variable_defined?(:it))
end

"foo".tap do
assert_equal([], binding.local_variables)
assert_raise(NameError) { binding.local_variable_get(:it) }
assert_equal(false, binding.local_variable_defined?(:it))
"bar".tap do
it
assert_equal([], binding.local_variables)
assert_raise(NameError) { binding.local_variable_get(:it) }
assert_equal(false, binding.local_variable_defined?(:it))
end
assert_equal([], binding.local_variables)
assert_raise(NameError) { binding.local_variable_get(:it) }
assert_equal(false, binding.local_variable_defined?(:it))
end
end

Expand Down
9 changes: 9 additions & 0 deletions test/ruby/test_zjit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,15 @@ def entry = test(e: :e, d: :d, c: :c, a: :a, b: :b)
}, call_threshold: 2
end

def test_send_kwsplat
assert_compiles '3', %q{
def test(a:) = a
def entry = test(**{a: 3})
entry
entry
}, call_threshold: 2
end

def test_send_kwrest
assert_compiles '{a: 3}', %q{
def test(**kwargs) = kwargs
Expand Down
4 changes: 2 additions & 2 deletions thread_pthread_mn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1078,12 +1078,12 @@ timer_thread_polling(rb_vm_t *vm)

switch (r) {
case 0: // timeout
rb_native_mutex_lock(&vm->ractor.sched.lock);
ractor_sched_lock(vm, NULL);
{
// (1-1) timeslice
timer_thread_check_timeslice(vm);
}
rb_native_mutex_unlock(&vm->ractor.sched.lock);
ractor_sched_unlock(vm, NULL);
break;

case -1: // error
Expand Down
41 changes: 7 additions & 34 deletions tool/format-release
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ end

require "open-uri"
require "yaml"
require_relative "./ruby-version"

Diffy::Diff.default_options.merge!(
include_diff_info: true,
Expand Down Expand Up @@ -54,30 +55,10 @@ eom
unless /\A(\d+)\.(\d+)\.(\d+)(?:-(?:preview|rc)\d+)?\z/ =~ version
raise "unexpected version string '#{version}'"
end
x = $1.to_i
y = $2.to_i
z = $3.to_i
# previous tag for git diff --shortstat
# It's only for x.y.0 release
if z != 0
prev_tag = nil
elsif y != 0
prev_ver = "#{x}.#{y-1}.0"
prev_tag = version_tag(prev_ver)
else # y == 0 && z == 0
case x
when 3
prev_ver = "2.7.0"
when 4
prev_ver = "3.4.0"
else
raise "it doesn't know what is the previous version of '#{version}'"
end
prev_tag = version_tag(prev_ver)
end
teeny = Integer($3)

uri = "https://cache.ruby-lang.org/pub/tmp/ruby-info-#{version}-draft.yml"
info = YAML.load(URI(uri).read)
info = YAML.unsafe_load(URI(uri).read)
if info.size != 1
raise "unexpected info.yml '#{uri}'"
end
Expand All @@ -92,9 +73,10 @@ eom
tarballs << tarball
end

if prev_tag
if teeny == 0
# show diff shortstat
tag = version_tag(version)
tag = RubyVersion.tag(version)
prev_tag = RubyVersion.tag(RubyVersion.previous(version))
stat = `git -C #{rubydir} diff -l0 --shortstat #{prev_tag}..#{tag}`
files_changed, insertions, deletions = stat.scan(/\d+/)
end
Expand Down Expand Up @@ -188,7 +170,7 @@ eom
if /\.0(?:-\w+)?\z/ =~ ver
# preview, rc, or first release
entry <<= <<eom
tag: #{version_tag(ver)}
tag: #{RubyVersion.tag(ver)}
stats:
files_changed: #{files_changed}
insertions: #{insertions}
Expand Down Expand Up @@ -247,15 +229,6 @@ eom
puts line
end
end

def self.version_tag(version)
major_version = Integer(version.split('.', 2)[0])
if major_version >= 4
"v#{version}"
else
"v#{version.tr('.-', '_')}"
end
end
end

def main
Expand Down
12 changes: 10 additions & 2 deletions tool/make-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,18 @@ def package(vcs, rev, destdir, tmp = nil)
when /\A(\d+)\.(\d+)\.(\d+)-(preview|rc)(\d+)/
prerelease = true
tag = "#{$4}#{$5}"
url = vcs.tag("v#{$1}_#{$2}_#{$3}_#{$4}#{$5}")
if Integer($1) >= 4
url = vcs.tag("v#{rev}")
else
url = vcs.tag("v#{$1}_#{$2}_#{$3}_#{$4}#{$5}")
end
when /\A(\d+)\.(\d+)\.(\d+)\z/
tag = ""
url = vcs.tag("v#{$1}_#{$2}_#{$3}")
if Integer($1) >= 4
url = vcs.tag("v#{rev}")
else
url = vcs.tag("v#{$1}_#{$2}_#{$3}")
end
when /\A(\d+)\.(\d+)\z/
url = vcs.branch("ruby_#{rev.tr('.', '_')}")
else
Expand Down
39 changes: 6 additions & 33 deletions tool/releng/update-www-meta.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby
require "open-uri"
require "yaml"
require_relative "../ruby-version"

class Tarball
attr_reader :version, :size, :sha1, :sha256, :sha512
Expand Down Expand Up @@ -41,27 +42,7 @@ def self.parse(wwwdir, version)
unless /\A(\d+)\.(\d+)\.(\d+)(?:-(?:preview|rc)\d+)?\z/ =~ version
raise "unexpected version string '#{version}'"
end
x = $1.to_i
y = $2.to_i
z = $3.to_i
# previous tag for git diff --shortstat
# It's only for x.y.0 release
if z != 0
prev_tag = nil
elsif y != 0
prev_ver = "#{x}.#{y-1}.0"
prev_tag = version_tag(prev_ver)
else # y == 0 && z == 0
case x
when 3
prev_ver = "2.7.0"
when 4
prev_ver = "3.4.0"
else
raise "it doesn't know what is the previous version of '#{version}'"
end
prev_tag = version_tag(prev_ver)
end
teeny = Integer($3)

uri = "https://cache.ruby-lang.org/pub/tmp/ruby-info-#{version}-draft.yml"
info = YAML.load(URI(uri).read)
Expand All @@ -79,9 +60,10 @@ def self.parse(wwwdir, version)
tarballs << tarball
end

if prev_tag
if teeny == 0
# show diff shortstat
tag = version_tag(version)
tag = RubyVersion.tag(version)
prev_tag = RubyVersion.tag(RubyVersion.previous(version))
rubydir = File.expand_path(File.join(__FILE__, '../../../'))
puts %`git -C #{rubydir} diff --shortstat #{prev_tag}..#{tag}`
stat = `git -C #{rubydir} diff --shortstat #{prev_tag}..#{tag}`
Expand Down Expand Up @@ -160,7 +142,7 @@ def self.update_releases_yml(ver, xy, ary, wwwdir, files_changed, insertions, de
date = Time.now.utc # use utc to use previous day in midnight
entry = <<eom
- version: #{ver}
tag: #{version_tag(ver)}
tag: #{RubyVersion.tag(ver)}
date: #{date.strftime("%Y-%m-%d")}
post: /en/news/#{date.strftime("%Y/%m/%d")}/ruby-#{ver.tr('.', '-')}-released/
stats:
Expand Down Expand Up @@ -196,15 +178,6 @@ def self.update_releases_yml(ver, xy, ary, wwwdir, files_changed, insertions, de
end
File.write(File.join(wwwdir, filename), data)
end

def self.version_tag(version)
major_version = Integer(version.split('.', 2)[0])
if major_version >= 4
"v#{version}"
else
"v#{version.tr('.-', '_')}"
end
end
end

# Confirm current directory is www.ruby-lang.org's working directory
Expand Down
52 changes: 52 additions & 0 deletions tool/ruby-version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env ruby

module RubyVersion
def self.tag(version)
major_version = Integer(version.split('.', 2)[0])
if major_version >= 4
"v#{version}"
else
"v#{version.tr('.-', '_')}"
end
end

# Return the previous version to be used for release diff links.
# For a ".0" version, it returns the previous ".0" version.
# For a non-".0" version, it returns the previous teeny version.
def self.previous(version)
unless /\A(\d+)\.(\d+)\.(\d+)(?:-(?:preview|rc)\d+)?\z/ =~ version
raise "unexpected version string '#{version}'"
end
major = Integer($1)
minor = Integer($2)
teeny = Integer($3)

if teeny != 0
"#{major}.#{minor}.#{teeny-1}"
elsif minor != 0 # && teeny == 0
"#{major}.#{minor-1}.#{teeny}"
else # minor == 0 && teeny == 0
case major
when 3
"2.7.0"
when 4
"3.4.0"
else
raise "it doesn't know what is the previous version of '#{version}'"
end
end
end
end

if __FILE__ == $0
case ARGV[0]
when "tag"
print RubyVersion.tag(ARGV[1])
when "previous"
print RubyVersion.previous(ARGV[1])
when "previous-tag"
print RubyVersion.tag(RubyVersion.previous(ARGV[1]))
else
"#{$0}: unexpected command #{ARGV[0].inspect}"
end
end
Loading