Skip to content

Commit 06485a3

Browse files
authored
Merge branch 'master' into fix-docs-build-with-rbs
2 parents 0d13ef2 + 03093ba commit 06485a3

54 files changed

Lines changed: 634 additions & 292 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ d1474affa8e105bece209cc9d594bb0a989859e1
1414

1515
# Indentation
1616
0e4bad888e605d424b9222ae0ca43f85c1634e5e
17+
61aa46c41648c6d1e9b0daa1a292de551fde78df
1718

1819
# Enable Style/StringLiterals cop for RubyGems/Bundler
1920
d7ffd3fea402239b16833cc434404a7af82d44f3
@@ -42,6 +43,8 @@ d4e24021d39e1f80f0055b55d91f8d5f22e15084
4243
e90282be7ba1bc8e3119f6e1a2c80356ceb3f80a
4344
26a9e0b4e31f7b5a9cbd755e0a15823a8fa51bae
4445
2f53985da9ee593fe524d408256835667938c7d7
46+
bf01f6ae89a95d8f5572e050facfe311c8c28aaf
47+
7480cd8d37fd71a41ce12b759090051c7e14fb5a
4548

4649
# Win32: EOL code of batch files
4750
23f9a0d655c4d405bb2397a147a1523436205486
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Setup directories etc.
2+
description: >-
3+
Build baseruby for cross-compiling
4+
5+
inputs:
6+
srcdir:
7+
required: true
8+
default: ${{ github.workspace }}
9+
description: >-
10+
Directory of source codes.
11+
12+
builddir:
13+
required: false
14+
default: ${{ github.workspace }}/baseruby
15+
description: >-
16+
Where baseruby will be built.
17+
18+
installdir:
19+
required: false
20+
default: install
21+
description: >-
22+
The path where the baseruby will be installed to.
23+
This is relative from the workspace.
24+
25+
outputs:
26+
ruby:
27+
value: ${{ steps.build.outputs.installdir }}/bin/ruby
28+
description: >-
29+
The path of the executable baseruby.
30+
dump_ast:
31+
value: ${{ steps.build.outputs.installdir }}/bin/dump_ast
32+
description: >-
33+
The path of the executable dump_ast.
34+
35+
runs:
36+
using: composite
37+
38+
steps:
39+
- name: Build baseruby
40+
shell: bash
41+
id: build
42+
run: |
43+
case "$installdir" in /*) ;; *) installdir="$PWD/$installdir";; esac
44+
mkdir "$builddir"
45+
ln -sr "$srcdir" "$builddir/.src"
46+
pushd "$builddir"
47+
.src/configure "--prefix=${installdir}" --disable-install-doc
48+
CONFIGURE_ARGS=--with-out-ext=-test- make install
49+
install dump_ast "${installdir}/bin"
50+
{
51+
echo "${installdir}/bin/dump_ast"
52+
echo "${installdir}/.installed.list"
53+
echo "${installdir}/"
54+
} >> .installed.list
55+
cp .installed.list "${installdir}/"
56+
make distclean
57+
rm .src
58+
popd
59+
rmdir "$builddir"
60+
{
61+
echo "installdir=${installdir}"
62+
} | tee -a "$GITHUB_OUTPUT"
63+
env:
64+
srcdir: ${{ inputs.srcdir }}
65+
builddir: ${{ inputs.builddir }}
66+
installdir: ${{ inputs.installdir }}
67+
68+
- name: clean
69+
uses: gacts/run-and-post-run@598d7a875d5620e0457490555b5e18e46082aa47 # v1.4.4
70+
with:
71+
working-directory: ${{ inputs.srcdir }}
72+
post: |
73+
ruby tool/rbuninstall.rb "${{ steps.build.outputs.installdir }}/.installed.list" > /dev/null

.github/actions/setup/ubuntu/action.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,45 @@ runs:
2424
using: composite
2525

2626
steps:
27+
- id: uname
28+
name: uname
29+
shell: bash
30+
env:
31+
arch: ${{ inputs.arch }}
32+
run: |
33+
setarch="${arch:+setarch $arch --}"
34+
# normalize `uname`
35+
if uname=$(${setarch} uname -m 2> /dev/null); then
36+
# `setarch` works, `$arch` is a valid architecture name.
37+
echo "setarch=${setarch}" >> "$GITHUB_OUTPUT"
38+
else
39+
# if `setarch` failed, take the given `arch` as-is.
40+
uname="${arch}"
41+
setarch=""
42+
fi
43+
echo "uname=$uname" >> "$GITHUB_OUTPUT"
44+
echo "dpkg=${uname/686/386}" >> "$GITHUB_OUTPUT"
45+
2746
- name: set SETARCH
2847
shell: bash
2948
run: echo "SETARCH=${setarch}" >> "$GITHUB_ENV" # zizmor: ignore[github-env]
3049
env:
31-
setarch: ${{ inputs.arch && format('setarch {0} --', inputs.arch) }}
50+
setarch: ${{ steps.uname.outputs.setarch }} # validated
3251

33-
- id: uname
34-
name: uname
52+
- name: dpkg setup
3553
shell: bash
36-
run: |
37-
echo uname=`${SETARCH} uname -m` >> "$GITHUB_OUTPUT"
38-
echo dpkg=`${SETARCH} uname -m | sed s/686/386/` >> "$GITHUB_OUTPUT"
54+
run: sudo dpkg --add-architecture "${dpkg}"
55+
# `dpkg` is valid, also `uname`.
56+
if: ${{ inputs.arch }}
57+
env:
58+
dpkg: ${{ steps.uname.outputs.dpkg }}
3959

4060
- name: apt-get
4161
shell: bash
4262
env:
4363
arch: ${{ inputs.arch && format(':{0}', steps.uname.outputs.dpkg) || '' }}
4464
run: |
4565
set -x
46-
${arch:+sudo dpkg --add-architecture ${arch#:}}
4766
sudo apt-get update -qq || :
4867
sudo apt-get install --no-install-recommends -qq -y -o=Dpkg::Use-Pty=0 \
4968
${arch:+cross}build-essential${arch/:/-} \

.github/workflows/crosscompile.yml

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@ jobs:
6464
builddir: build
6565
makeup: true
6666

67-
- name: Install cross-compilation toolchain
67+
- name: Setup cross-compilation toolchain sources
6868
run: |
69-
sudo dpkg --add-architecture ${{ matrix.arch }}
7069
native_arch=$(dpkg --print-architecture)
7170
# Restrict existing sources to native arch
7271
sudo sed -i '/^Architectures:/d' /etc/apt/sources.list.d/ubuntu.sources
@@ -84,32 +83,25 @@ jobs:
8483
"Components: main universe" \
8584
"Architectures: ${{ matrix.arch }}" \
8685
| sudo tee /etc/apt/sources.list.d/cross-${{ matrix.arch }}.sources
87-
sudo apt-get update -qq
88-
sudo apt-get install --no-install-recommends -qq -y \
89-
crossbuild-essential-${{ matrix.arch }} \
90-
libssl-dev:${{ matrix.arch }} \
91-
libyaml-dev:${{ matrix.arch }} \
92-
zlib1g-dev:${{ matrix.arch }} \
93-
libffi-dev:${{ matrix.arch }} \
94-
libreadline-dev:${{ matrix.arch }} \
95-
libncurses-dev:${{ matrix.arch }} \
96-
autoconf ruby
97-
98-
- name: Build baseruby
99-
run: |
100-
mkdir ../baseruby
101-
cd ../baseruby
102-
../src/configure --prefix=$PWD/install --disable-install-doc
103-
make
104-
make install
86+
87+
- uses: ./.github/actions/setup/ubuntu
88+
with:
89+
arch: ${{ matrix.arch }}
90+
91+
- uses: ./.github/actions/setup/baseruby
92+
id: baseruby
93+
with:
94+
srcdir: src
10595

10696
- name: Run configure
10797
run: >-
10898
../src/configure -C --disable-install-doc
10999
--prefix=/usr
110100
--build=${{ matrix.build }}
111101
--host=${{ matrix.host }}
112-
--with-baseruby=$PWD/../baseruby/install/bin/ruby
102+
--with-baseruby="$baseruby"
103+
env:
104+
baseruby: ${{ steps.baseruby.outputs.ruby }}
113105

114106
- run: make
115107

.github/workflows/wasm.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,10 @@ jobs:
104104
run: |
105105
echo "WASI_SDK_PATH=/opt/wasi-sdk" >> $GITHUB_ENV
106106
107-
- name: Build baseruby
107+
- uses: ./.github/actions/setup/baseruby
108108
id: baseruby
109-
run: |
110-
set -ex
111-
mkdir ../baseruby
112-
pushd ../baseruby
113-
echo "ruby=$PWD/install/bin/ruby" >> $GITHUB_OUTPUT
114-
echo "dump_ast=$PWD/dump_ast" >> $GITHUB_OUTPUT
115-
../src/configure --prefix=$PWD/install
116-
make
117-
make install
109+
with:
110+
srcdir: src
118111

119112
- name: Download config.guess with wasi version
120113
run: |

.github/workflows/zjit-macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393
rustup install ${{ matrix.rust_version }} --profile minimal
9494
rustup default ${{ matrix.rust_version }}
9595
96-
- uses: taiki-e/install-action@3235f8901fd37ffed0052b276cec25a362fb82e9 # v2.77.7
96+
- uses: taiki-e/install-action@e1c4cd42111751368541a7cb5db3522bd1f846a4 # v2.78.0
9797
with:
9898
tool: nextest@0.9
9999
if: ${{ matrix.test_task == 'zjit-check' }}

.github/workflows/zjit-ubuntu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ jobs:
119119
ruby-version: '3.1'
120120
bundler: none
121121

122-
- uses: taiki-e/install-action@3235f8901fd37ffed0052b276cec25a362fb82e9 # v2.77.7
122+
- uses: taiki-e/install-action@e1c4cd42111751368541a7cb5db3522bd1f846a4 # v2.78.0
123123
with:
124124
tool: nextest@0.9
125125
if: ${{ matrix.test_task == 'zjit-check' }}

NEWS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,10 @@ releases.
107107
* test-unit 3.7.7
108108
* 3.7.5 to [3.7.6][test-unit-3.7.6], [3.7.7][test-unit-3.7.7]
109109
* net-imap 0.6.4
110-
* 0.6.2 to [v0.6.3][net-imap-v0.6.3]
110+
* 0.6.2 to [v0.6.3][net-imap-v0.6.3], [v0.6.4][net-imap-v0.6.4]
111111
* rbs 4.0.2
112112
* 3.10.0 to [v3.10.1][rbs-v3.10.1], [v3.10.2][rbs-v3.10.2], [v3.10.3][rbs-v3.10.3], [v3.10.4][rbs-v3.10.4], [v4.0.0.dev.5][rbs-v4.0.0.dev.5], [v4.0.0][rbs-v4.0.0], [v4.0.2][rbs-v4.0.2]
113+
* typeprof 0.32.0
113114
* mutex_m 0.3.0
114115
* bigdecimal 4.1.2
115116
* 4.0.1 to [v4.1.0][bigdecimal-v4.1.0], [v4.1.1][bigdecimal-v4.1.1], [v4.1.2][bigdecimal-v4.1.2]
@@ -221,6 +222,7 @@ A lot of work has gone into making Ractors more stable, performant, and usable.
221222
[test-unit-3.7.6]: https://github.com/test-unit/test-unit/releases/tag/3.7.6
222223
[test-unit-3.7.7]: https://github.com/test-unit/test-unit/releases/tag/3.7.7
223224
[net-imap-v0.6.3]: https://github.com/ruby/net-imap/releases/tag/v0.6.3
225+
[net-imap-v0.6.4]: https://github.com/ruby/net-imap/releases/tag/v0.6.4
224226
[rbs-v3.10.1]: https://github.com/ruby/rbs/releases/tag/v3.10.1
225227
[rbs-v3.10.2]: https://github.com/ruby/rbs/releases/tag/v3.10.2
226228
[rbs-v3.10.3]: https://github.com/ruby/rbs/releases/tag/v3.10.3

benchmark/string_gsub.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,19 @@ prelude: |
2020
}
2121
ESCAPE_PATTERN = Regexp.union(ESCAPED_CHARS.keys)
2222
23+
NO_MATCH_SHARED_STRING = ("a" * 100_000).freeze
2324
2425
benchmark:
26+
gsub_no_match_shared: |
27+
str = NO_MATCH_SHARED_STRING.dup
28+
str.gsub!("z", "x")
29+
str
30+
31+
sub_no_match_shared: |
32+
str = NO_MATCH_SHARED_STRING.dup
33+
str.sub!("z", "x")
34+
str
35+
2536
escape: |
2637
str = STR.dup
2738
str.gsub!(ESCAPE_PATTERN, ESCAPED_CHARS)

doc/syntax/refinements.rdoc

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -210,40 +210,58 @@ all refinements from the same module are active when a refined method
210210

211211
== Method Lookup
212212

213-
When looking up a method for an instance of class +C+ Ruby checks:
213+
Method lookup in Ruby is based on the ancestor chain. You can see the
214+
ancestor chain for any object in Ruby by doing:
214215

215-
* The refinements of +C+, in reverse order of activation
216-
* The prepended modules of +C+
217-
* +C+
218-
* The included modules of +C+
216+
object.singleton_class.ancestors
217+
# or, if the object does not support a singleton class:
218+
object.class.ancestors
219219

220-
If no method was found at any point this repeats with the superclass of +C+.
220+
The ancestor chain is constructed as follows:
221221

222-
Note that methods in a subclass have priority over refinements in a
223-
superclass. For example, if the method <code>/</code> is defined in a
224-
refinement for Numeric <code>1 / 2</code> invokes the original Integer#/
225-
because Integer is a subclass of Numeric and is searched before the refinements
226-
for the superclass Numeric. Since the method <code>/</code> is also present
227-
in child +Integer+, the method lookup does not move up to the superclass.
222+
* Subclasses are before superclasses in the ancestor chain
223+
* Prepended modules are before the class they prepend in the ancestor
224+
chain, in reverse order in which they were prepended.
225+
* Included modules are after the class they are included in in the
226+
ancestor chain, in reverse order in which they were included.
227+
228+
When looking up a method for an object, Ruby goes through each ancestor:
229+
230+
* If the class/module has been refined, Ruby will consider the refinements
231+
activated at the point the method was called, in reverse order of
232+
activation.
233+
* Otherwise, Ruby will check the methods of the class/module itself.
234+
235+
If no method was found at either point this repeats with the next
236+
ancestor.
228237

229-
However, if a method +foo+ is defined on Numeric in a refinement, <code>1.foo</code>
238+
Note that methods in a earlier ancestor have priority over refinements in a
239+
later ancestor. For example, if the method <code>/</code> is defined in a
240+
refinement for Numeric <code>1 / 2</code> invokes the original Integer#/
241+
because Integer is a comes before Numeric in the ancestor chain. However,
242+
if a method +foo+ is defined on Numeric in a refinement, <code>1.foo</code>
230243
invokes that method since +foo+ does not exist on Integer.
231244

232245
== +super+
233246

234-
When +super+ is invoked method lookup checks:
247+
When +super+ is invoked, method lookup starts:
248+
249+
* If the method is in a refinement, at the refined class or module
250+
* Otherwise, at the next ancestor
251+
252+
Method lookup then proceeds as described in the Method Lookup section
253+
above.
235254

236-
* The included modules of the current class. Note that the current class may
237-
be a refinement.
238-
* If the current class is a refinement, the method lookup proceeds as in the
239-
Method Lookup section above.
240-
* If the current class has a direct superclass, the method proceeds as in the
241-
Method Lookup section above using the superclass.
255+
Refinements activated at the call site of a refinement method do not
256+
affect +super+ inside that method. Only refinements activated at the
257+
point +super+ was called affect method lookup for that +super+ call.
258+
You cannot use refinements to insert into the middle of a method
259+
lookup chain, only to insert at the start of a method lookup chain,
260+
unless you control the +super+ call sites.
242261

243-
Note that +super+ in a method of a refinement invokes the method in the
244-
refined class even if there is another refinement which has been activated in
245-
the same context. This is only true for +super+ in a method of a refinement, it
246-
does not apply to +super+ in a method in a module that is included in a refinement.
262+
Note that if you refine a module, the refinement method can call +super+
263+
to call the method in the module, but the method in the module cannot
264+
call +super+ to continue the method lookup process to further ancestors.
247265

248266
== Methods Introspection
249267

0 commit comments

Comments
 (0)