rbs 3.9.5 → 3.10.0
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 +4 -4
- data/.clang-format +74 -0
- data/.clangd +2 -0
- data/.github/workflows/c-check.yml +54 -0
- data/.github/workflows/comments.yml +3 -3
- data/.github/workflows/ruby.yml +34 -19
- data/.github/workflows/typecheck.yml +1 -1
- data/.github/workflows/windows.yml +1 -1
- data/.gitignore +4 -0
- data/CHANGELOG.md +49 -0
- data/README.md +38 -1
- data/Rakefile +152 -23
- data/config.yml +190 -62
- data/core/array.rbs +100 -46
- data/core/complex.rbs +32 -21
- data/core/dir.rbs +2 -2
- data/core/encoding.rbs +6 -9
- data/core/enumerable.rbs +90 -3
- data/core/enumerator.rbs +18 -1
- data/core/errno.rbs +8 -0
- data/core/errors.rbs +28 -1
- data/core/exception.rbs +2 -2
- data/core/fiber.rbs +5 -4
- data/core/file.rbs +27 -12
- data/core/file_test.rbs +1 -1
- data/core/float.rbs +209 -22
- data/core/gc.rbs +417 -281
- data/core/hash.rbs +1024 -727
- data/core/integer.rbs +78 -38
- data/core/io/buffer.rbs +18 -7
- data/core/io/wait.rbs +11 -33
- data/core/io.rbs +14 -12
- data/core/kernel.rbs +57 -51
- data/core/marshal.rbs +1 -1
- data/core/match_data.rbs +1 -1
- data/core/math.rbs +42 -3
- data/core/method.rbs +14 -6
- data/core/module.rbs +88 -17
- data/core/nil_class.rbs +3 -3
- data/core/numeric.rbs +16 -16
- data/core/object.rbs +3 -3
- data/core/object_space.rbs +21 -15
- data/{stdlib/pathname/0 → core}/pathname.rbs +255 -355
- data/core/proc.rbs +15 -8
- data/core/process.rbs +2 -2
- data/core/ractor.rbs +278 -437
- data/core/range.rbs +7 -8
- data/core/rational.rbs +37 -24
- data/core/rbs/unnamed/argf.rbs +2 -2
- data/core/rbs/unnamed/env_class.rbs +1 -1
- data/core/rbs/unnamed/random.rbs +4 -2
- data/core/regexp.rbs +25 -20
- data/core/ruby.rbs +53 -0
- data/core/ruby_vm.rbs +6 -4
- data/core/rubygems/errors.rbs +3 -70
- data/core/rubygems/rubygems.rbs +11 -79
- data/core/rubygems/version.rbs +2 -3
- data/core/set.rbs +488 -359
- data/core/string.rbs +3145 -1231
- data/core/struct.rbs +1 -1
- data/core/symbol.rbs +4 -4
- data/core/thread.rbs +92 -29
- data/core/time.rbs +35 -9
- data/core/trace_point.rbs +7 -4
- data/core/unbound_method.rbs +14 -6
- data/docs/aliases.md +79 -0
- data/docs/collection.md +2 -2
- data/docs/encoding.md +56 -0
- data/docs/gem.md +0 -1
- data/docs/sigs.md +3 -3
- data/ext/rbs_extension/ast_translation.c +1016 -0
- data/ext/rbs_extension/ast_translation.h +37 -0
- data/ext/rbs_extension/class_constants.c +155 -0
- data/{include/rbs/constants.h → ext/rbs_extension/class_constants.h} +7 -1
- data/ext/rbs_extension/compat.h +10 -0
- data/ext/rbs_extension/extconf.rb +25 -1
- data/ext/rbs_extension/legacy_location.c +317 -0
- data/ext/rbs_extension/legacy_location.h +45 -0
- data/ext/rbs_extension/main.c +357 -14
- data/ext/rbs_extension/rbs_extension.h +6 -21
- data/ext/rbs_extension/rbs_string_bridging.c +9 -0
- data/ext/rbs_extension/rbs_string_bridging.h +24 -0
- data/include/rbs/ast.h +687 -0
- data/include/rbs/defines.h +86 -0
- data/include/rbs/lexer.h +199 -0
- data/include/rbs/location.h +59 -0
- data/include/rbs/parser.h +135 -0
- data/include/rbs/string.h +47 -0
- data/include/rbs/util/rbs_allocator.h +59 -0
- data/include/rbs/util/rbs_assert.h +20 -0
- data/include/rbs/util/rbs_buffer.h +83 -0
- data/include/rbs/util/rbs_constant_pool.h +6 -67
- data/include/rbs/util/rbs_encoding.h +282 -0
- data/include/rbs/util/rbs_unescape.h +24 -0
- data/include/rbs.h +1 -2
- data/lib/rbs/annotate/formatter.rb +3 -13
- data/lib/rbs/annotate/rdoc_annotator.rb +3 -1
- data/lib/rbs/annotate/rdoc_source.rb +1 -1
- data/lib/rbs/cli/validate.rb +2 -2
- data/lib/rbs/cli.rb +1 -1
- data/lib/rbs/collection/config/lockfile_generator.rb +1 -0
- data/lib/rbs/definition_builder/ancestor_builder.rb +5 -5
- data/lib/rbs/environment.rb +64 -59
- data/lib/rbs/environment_loader.rb +1 -1
- data/lib/rbs/errors.rb +1 -1
- data/lib/rbs/parser_aux.rb +5 -0
- data/lib/rbs/resolver/constant_resolver.rb +2 -2
- data/lib/rbs/resolver/type_name_resolver.rb +124 -38
- data/lib/rbs/test/type_check.rb +14 -0
- data/lib/rbs/types.rb +3 -1
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +1 -1
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +3 -3
- data/sig/annotate/formatter.rbs +2 -2
- data/sig/annotate/rdoc_annotater.rbs +1 -1
- data/sig/environment.rbs +57 -6
- data/sig/manifest.yaml +0 -1
- data/sig/parser.rbs +20 -0
- data/sig/resolver/type_name_resolver.rbs +38 -7
- data/sig/types.rbs +4 -1
- data/src/ast.c +1256 -0
- data/src/lexer.c +2956 -0
- data/src/lexer.re +147 -0
- data/src/lexstate.c +205 -0
- data/src/location.c +71 -0
- data/src/parser.c +3507 -0
- data/src/string.c +41 -0
- data/src/util/rbs_allocator.c +152 -0
- data/src/util/rbs_assert.c +19 -0
- data/src/util/rbs_buffer.c +54 -0
- data/src/util/rbs_constant_pool.c +18 -88
- data/src/util/rbs_encoding.c +21308 -0
- data/src/util/rbs_unescape.c +167 -0
- data/stdlib/bigdecimal/0/big_decimal.rbs +100 -82
- data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
- data/stdlib/cgi/0/core.rbs +2 -396
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/cgi-escape/0/escape.rbs +153 -0
- data/stdlib/coverage/0/coverage.rbs +3 -1
- data/stdlib/date/0/date.rbs +67 -59
- data/stdlib/date/0/date_time.rbs +1 -1
- data/stdlib/delegate/0/delegator.rbs +10 -7
- data/stdlib/erb/0/erb.rbs +737 -347
- data/stdlib/fileutils/0/fileutils.rbs +18 -13
- data/stdlib/forwardable/0/forwardable.rbs +3 -0
- data/stdlib/json/0/json.rbs +68 -48
- data/stdlib/net-http/0/net-http.rbs +3 -0
- data/stdlib/objspace/0/objspace.rbs +9 -4
- data/stdlib/open-uri/0/open-uri.rbs +40 -0
- data/stdlib/openssl/0/openssl.rbs +331 -228
- data/stdlib/optparse/0/optparse.rbs +3 -3
- data/stdlib/psych/0/psych.rbs +3 -3
- data/stdlib/rdoc/0/code_object.rbs +2 -2
- data/stdlib/rdoc/0/comment.rbs +2 -0
- data/stdlib/rdoc/0/options.rbs +76 -0
- data/stdlib/rdoc/0/rdoc.rbs +7 -5
- data/stdlib/rdoc/0/store.rbs +1 -1
- data/stdlib/resolv/0/resolv.rbs +25 -68
- data/stdlib/ripper/0/ripper.rbs +5 -2
- data/stdlib/singleton/0/singleton.rbs +3 -0
- data/stdlib/socket/0/socket.rbs +13 -1
- data/stdlib/socket/0/tcp_socket.rbs +10 -2
- data/stdlib/stringio/0/stringio.rbs +1176 -85
- data/stdlib/strscan/0/string_scanner.rbs +31 -31
- data/stdlib/tempfile/0/tempfile.rbs +3 -3
- data/stdlib/time/0/time.rbs +1 -1
- data/stdlib/timeout/0/timeout.rbs +63 -7
- data/stdlib/tsort/0/cyclic.rbs +3 -0
- data/stdlib/uri/0/common.rbs +11 -2
- data/stdlib/uri/0/file.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +17 -16
- data/stdlib/uri/0/rfc2396_parser.rbs +6 -7
- data/stdlib/zlib/0/zstream.rbs +1 -0
- metadata +43 -18
- data/ext/rbs_extension/lexer.c +0 -2728
- data/ext/rbs_extension/lexer.h +0 -179
- data/ext/rbs_extension/lexer.re +0 -147
- data/ext/rbs_extension/lexstate.c +0 -175
- data/ext/rbs_extension/location.c +0 -325
- data/ext/rbs_extension/location.h +0 -85
- data/ext/rbs_extension/parser.c +0 -2982
- data/ext/rbs_extension/parser.h +0 -18
- data/ext/rbs_extension/parserstate.c +0 -411
- data/ext/rbs_extension/parserstate.h +0 -163
- data/ext/rbs_extension/unescape.c +0 -32
- data/include/rbs/ruby_objs.h +0 -72
- data/src/constants.c +0 -153
- data/src/ruby_objs.c +0 -799
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a9e4107a0a29610713b34bf84a13fd4e348257e56e865a40358e61312f158fe0
|
|
4
|
+
data.tar.gz: d9776ace0cb6e68ba97cd4bcdd2ade5e41ba909dbf562914053d64afad118d1c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8805e28d9b760da1aa847fb8fa5ed26f26a2dc7309a37d861a178a511bfac68181955324803b42f64aada55cdd8806522c682b0980457aded2279f6493611eb0
|
|
7
|
+
data.tar.gz: 4ffa069bffbcaa8e869d30f50dbe42344f624691acea5e9aa1ff8c665f4749c32c8450d5b2dab0e6ed3fc94e4bc67f8c82a833ac5cb167f35c4cb17eaeb59d45
|
data/.clang-format
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
Language: Cpp
|
|
3
|
+
|
|
4
|
+
# Indentation
|
|
5
|
+
UseTab: Never
|
|
6
|
+
IndentWidth: 4
|
|
7
|
+
BreakBeforeBraces: Attach
|
|
8
|
+
IndentCaseLabels: false
|
|
9
|
+
NamespaceIndentation: None
|
|
10
|
+
ContinuationIndentWidth: 4
|
|
11
|
+
IndentPPDirectives: None
|
|
12
|
+
IndentWrappedFunctionNames: false
|
|
13
|
+
AccessModifierOffset: -2
|
|
14
|
+
|
|
15
|
+
# Alignment
|
|
16
|
+
AlignAfterOpenBracket: BlockIndent
|
|
17
|
+
AlignConsecutiveAssignments: false
|
|
18
|
+
AlignConsecutiveDeclarations: false
|
|
19
|
+
AlignConsecutiveMacros: false
|
|
20
|
+
AlignEscapedNewlines: Left
|
|
21
|
+
AlignOperands: false
|
|
22
|
+
AlignTrailingComments: true
|
|
23
|
+
DerivePointerAlignment: false
|
|
24
|
+
PointerAlignment: Right
|
|
25
|
+
|
|
26
|
+
# Function calls formatting
|
|
27
|
+
BinPackArguments: false
|
|
28
|
+
BinPackParameters: false
|
|
29
|
+
AllowAllArgumentsOnNextLine: false
|
|
30
|
+
ExperimentalAutoDetectBinPacking: false
|
|
31
|
+
PenaltyBreakBeforeFirstCallParameter: 1
|
|
32
|
+
AlwaysBreakAfterDefinitionReturnType: None
|
|
33
|
+
|
|
34
|
+
# Wrapping and Breaking
|
|
35
|
+
ColumnLimit: 0
|
|
36
|
+
AllowShortBlocksOnASingleLine: Never
|
|
37
|
+
AllowShortCaseLabelsOnASingleLine: false
|
|
38
|
+
AllowShortFunctionsOnASingleLine: All
|
|
39
|
+
AllowShortIfStatementsOnASingleLine: Always
|
|
40
|
+
AllowShortLoopsOnASingleLine: false
|
|
41
|
+
AlwaysBreakAfterReturnType: None
|
|
42
|
+
AlwaysBreakBeforeMultilineStrings: false
|
|
43
|
+
AlwaysBreakTemplateDeclarations: No
|
|
44
|
+
BreakBeforeBinaryOperators: None
|
|
45
|
+
BreakBeforeTernaryOperators: false
|
|
46
|
+
BreakConstructorInitializers: BeforeColon
|
|
47
|
+
BreakInheritanceList: BeforeColon
|
|
48
|
+
BreakStringLiterals: false
|
|
49
|
+
CompactNamespaces: false
|
|
50
|
+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
|
51
|
+
Cpp11BracedListStyle: false
|
|
52
|
+
ReflowComments: false
|
|
53
|
+
SortIncludes: Never
|
|
54
|
+
|
|
55
|
+
# Spaces
|
|
56
|
+
SpaceAfterCStyleCast: true
|
|
57
|
+
SpaceAfterLogicalNot: false
|
|
58
|
+
SpaceAfterTemplateKeyword: true
|
|
59
|
+
SpaceBeforeAssignmentOperators: true
|
|
60
|
+
SpaceBeforeCpp11BracedList: true
|
|
61
|
+
SpaceBeforeCtorInitializerColon: true
|
|
62
|
+
SpaceBeforeInheritanceColon: true
|
|
63
|
+
SpaceBeforeParens: ControlStatements
|
|
64
|
+
SpaceBeforeRangeBasedForLoopColon: true
|
|
65
|
+
SpaceBeforeSquareBrackets: false
|
|
66
|
+
SpaceInEmptyBlock: false
|
|
67
|
+
SpaceInEmptyParentheses: false
|
|
68
|
+
SpacesBeforeTrailingComments: 1
|
|
69
|
+
SpacesInAngles: false
|
|
70
|
+
SpacesInCStyleCastParentheses: false
|
|
71
|
+
SpacesInConditionalStatement: false
|
|
72
|
+
SpacesInContainerLiterals: true
|
|
73
|
+
SpacesInParentheses: false
|
|
74
|
+
SpacesInSquareBrackets: false
|
data/.clangd
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
name: C Code Generation and Formatting Check
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request: {}
|
|
6
|
+
merge_group: {}
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
format-check:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
- uses: ruby/setup-ruby@v1
|
|
14
|
+
with:
|
|
15
|
+
ruby-version: "4.0.0-preview3"
|
|
16
|
+
bundler-cache: none
|
|
17
|
+
- name: Set working directory as safe
|
|
18
|
+
run: git config --global --add safe.directory $(pwd)
|
|
19
|
+
- name: Install dependencies
|
|
20
|
+
run: |
|
|
21
|
+
sudo apt-get update
|
|
22
|
+
sudo apt-get install -y libdb-dev curl autoconf automake m4 libtool
|
|
23
|
+
- name: Install clang-format from LLVM
|
|
24
|
+
run: |
|
|
25
|
+
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
|
26
|
+
sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-20 main"
|
|
27
|
+
sudo apt-get update
|
|
28
|
+
sudo apt-get install -y clang-format-20
|
|
29
|
+
sudo ln -sf /usr/bin/clang-format-20 /usr/local/bin/clang-format
|
|
30
|
+
clang-format --version
|
|
31
|
+
- name: Count processors
|
|
32
|
+
run: nproc
|
|
33
|
+
- name: Install Re2c
|
|
34
|
+
run: |
|
|
35
|
+
cd /tmp
|
|
36
|
+
curl -L https://github.com/skvadrik/re2c/archive/refs/tags/4.3.tar.gz > re2c-4.3.tar.gz
|
|
37
|
+
tar xf re2c-4.3.tar.gz
|
|
38
|
+
cd re2c-4.3
|
|
39
|
+
autoreconf -i -W all
|
|
40
|
+
./configure
|
|
41
|
+
make -j"$(nproc)" -l"$(nproc)"
|
|
42
|
+
sudo make install
|
|
43
|
+
- name: Update rubygems & bundler
|
|
44
|
+
run: |
|
|
45
|
+
ruby -v
|
|
46
|
+
gem update --system
|
|
47
|
+
- name: bin/setup
|
|
48
|
+
run: |
|
|
49
|
+
bin/setup
|
|
50
|
+
- name: Check C code generation and formatting
|
|
51
|
+
run: |
|
|
52
|
+
clang-format --version
|
|
53
|
+
bundle exec rake lexer templates compile confirm_lexer confirm_templates
|
|
54
|
+
bundle exec rake format:c_check
|
|
@@ -10,13 +10,13 @@ on:
|
|
|
10
10
|
jobs:
|
|
11
11
|
comments:
|
|
12
12
|
runs-on: "ubuntu-latest"
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
env:
|
|
14
|
+
RUBY_COMMIT: v4.0.0-preview3
|
|
15
15
|
steps:
|
|
16
16
|
- uses: actions/checkout@v4
|
|
17
17
|
- uses: ruby/setup-ruby@v1
|
|
18
18
|
with:
|
|
19
|
-
ruby-version: "
|
|
19
|
+
ruby-version: "4.0.0-preview3"
|
|
20
20
|
bundler: none
|
|
21
21
|
- name: Install dependencies
|
|
22
22
|
run: |
|
data/.github/workflows/ruby.yml
CHANGED
|
@@ -13,26 +13,24 @@ jobs:
|
|
|
13
13
|
strategy:
|
|
14
14
|
fail-fast: false
|
|
15
15
|
matrix:
|
|
16
|
-
ruby: ['3.
|
|
16
|
+
ruby: ['3.2', '3.3', '3.4', '4.0.0-preview3', head]
|
|
17
17
|
rubyopt: [""]
|
|
18
18
|
job:
|
|
19
19
|
- test
|
|
20
20
|
include:
|
|
21
21
|
- ruby: head
|
|
22
22
|
job: stdlib_test rubocop
|
|
23
|
-
- ruby: "
|
|
23
|
+
- ruby: "4.0.0-preview3"
|
|
24
24
|
job: stdlib_test
|
|
25
|
-
- ruby: "
|
|
25
|
+
- ruby: "4.0.0-preview3"
|
|
26
26
|
job: test
|
|
27
27
|
rubyopt: "--enable-frozen-string-literal"
|
|
28
|
-
- ruby: "
|
|
28
|
+
- ruby: "4.0.0-preview3"
|
|
29
29
|
job: stdlib_test
|
|
30
30
|
rubyopt: "--enable-frozen-string-literal"
|
|
31
|
-
- ruby: "
|
|
32
|
-
job: lexer templates compile confirm_lexer confirm_templates
|
|
33
|
-
- ruby: "3.4"
|
|
31
|
+
- ruby: "4.0.0-preview3"
|
|
34
32
|
job: rubocop validate test_doc build test_generate_stdlib raap
|
|
35
|
-
- ruby: "
|
|
33
|
+
- ruby: "4.0.0-preview3"
|
|
36
34
|
job: typecheck_test
|
|
37
35
|
env:
|
|
38
36
|
RANDOMIZE_STDLIB_TEST_ORDER: "true"
|
|
@@ -48,17 +46,6 @@ jobs:
|
|
|
48
46
|
run: |
|
|
49
47
|
sudo apt-get update
|
|
50
48
|
sudo apt-get install -y libdb-dev curl autoconf automake m4 libtool python3
|
|
51
|
-
- name: Install Re2c
|
|
52
|
-
if: ${{ contains(matrix.job, 'lexer') }}
|
|
53
|
-
run: |
|
|
54
|
-
cd /tmp
|
|
55
|
-
curl -L https://github.com/skvadrik/re2c/archive/refs/tags/3.1.tar.gz > re2c-3.1.tar.gz
|
|
56
|
-
tar xf re2c-3.1.tar.gz
|
|
57
|
-
cd re2c-3.1
|
|
58
|
-
autoreconf -i -W all
|
|
59
|
-
./configure
|
|
60
|
-
make
|
|
61
|
-
sudo make install
|
|
62
49
|
- name: Update rubygems & bundler
|
|
63
50
|
run: |
|
|
64
51
|
ruby -v
|
|
@@ -102,3 +89,31 @@ jobs:
|
|
|
102
89
|
- run: bundle exec rake test:valgrind
|
|
103
90
|
env:
|
|
104
91
|
RUBY_FREE_AT_EXIT: 1
|
|
92
|
+
C99_compile:
|
|
93
|
+
runs-on: macos-latest
|
|
94
|
+
strategy:
|
|
95
|
+
fail-fast: false
|
|
96
|
+
matrix:
|
|
97
|
+
ruby: ['4.0.0-preview3', head]
|
|
98
|
+
steps:
|
|
99
|
+
- uses: actions/checkout@v4
|
|
100
|
+
- name: Install dependencies
|
|
101
|
+
run: |
|
|
102
|
+
brew install ruby-build
|
|
103
|
+
- uses: ruby/setup-ruby@v1
|
|
104
|
+
with:
|
|
105
|
+
ruby-version: ${{ matrix.ruby }}
|
|
106
|
+
bundler: none
|
|
107
|
+
- name: Set working directory as safe
|
|
108
|
+
run: git config --global --add safe.directory $(pwd)
|
|
109
|
+
- name: Update rubygems & bundler
|
|
110
|
+
run: |
|
|
111
|
+
ruby -v
|
|
112
|
+
gem update --system
|
|
113
|
+
- name: clang version
|
|
114
|
+
run: clang --version
|
|
115
|
+
- name: bin/setup
|
|
116
|
+
run: |
|
|
117
|
+
bin/setup
|
|
118
|
+
- run: bundle exec rake clean compile_c99
|
|
119
|
+
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,54 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 3.10.0 (2025-12-23)
|
|
4
|
+
|
|
5
|
+
RBS 3.10.0 ships with a pure C parser implementation, signature updates for Ruby 4.0, and various bug fixes.
|
|
6
|
+
|
|
7
|
+
### Pure C parser implementation
|
|
8
|
+
|
|
9
|
+
The new parser implementation was announced at [RubyKaigi 2025](https://rubykaigi.org/2025/presentations/amomchilov.html) and is finally shipped as a RubyGem!
|
|
10
|
+
|
|
11
|
+
The new parser is faster than the one in 3.9 and is portable — it is independent of the Ruby runtime and is used to implement Sorbet’s RBS support.
|
|
12
|
+
|
|
13
|
+
### Type definition of bundled gems
|
|
14
|
+
|
|
15
|
+
The type definitions of `cgi` have been moved to [gem_rbs_collection](https://github.com/ruby/gem_rbs_collection/tree/main/gems/cgi), as it has been migrated to a bundled gem in Ruby 4.0
|
|
16
|
+
|
|
17
|
+
`cgi-escape` has been added to `stdlib`. You may need to declare a dependency on `cgi-escape` in your `manifest.yaml`, add `-r cgi-escape` to your command line, or update your type checker configuration.
|
|
18
|
+
|
|
19
|
+
```yaml
|
|
20
|
+
dependencies:
|
|
21
|
+
- name: cgi-escape
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The type definitions for `pathname` have also been moved from `stdlib` to `core`, as it is now implemented as part of the core library.
|
|
25
|
+
|
|
26
|
+
### Pull Requests
|
|
27
|
+
|
|
28
|
+
* [Backport] Support rdoc v7 ([#2770](https://github.com/ruby/rbs/pull/2770))
|
|
29
|
+
* [Backport] Check tuple type length ([#2766](https://github.com/ruby/rbs/pull/2766))
|
|
30
|
+
* Backport update to 4.0.0-preview3 ([#2768](https://github.com/ruby/rbs/pull/2768))
|
|
31
|
+
* [Backport] Remove test code for bundled gems ([#2762](https://github.com/ruby/rbs/pull/2762))
|
|
32
|
+
* Merge pull request #2761 from ruby/update-minitest ([#2763](https://github.com/ruby/rbs/pull/2763))
|
|
33
|
+
* [Backport] Support BigDecimal v4 ([#2759](https://github.com/ruby/rbs/pull/2759))
|
|
34
|
+
* Parser/lexer backports ([#2756](https://github.com/ruby/rbs/pull/2756))
|
|
35
|
+
* Merge pull request #2753 from ruby/delete-printf ([#2754](https://github.com/ruby/rbs/pull/2754))
|
|
36
|
+
* Backports ([#2751](https://github.com/ruby/rbs/pull/2751))
|
|
37
|
+
* Merge pull request #2728 from ruby/cgi ([#2747](https://github.com/ruby/rbs/pull/2747))
|
|
38
|
+
* Merge pull request #2729 from ruby/rbs-assert ([#2748](https://github.com/ruby/rbs/pull/2748))
|
|
39
|
+
* Merge pull request #2749 from ruby/fix-test ([#2750](https://github.com/ruby/rbs/pull/2750))
|
|
40
|
+
* Backport RBS file updates ([#2742](https://github.com/ruby/rbs/pull/2742))
|
|
41
|
+
* Backport JSON PRs ([#2740](https://github.com/ruby/rbs/pull/2740))
|
|
42
|
+
* Merge pull request #2718 from ruby/ruby-4 ([#2741](https://github.com/ruby/rbs/pull/2741))
|
|
43
|
+
* [Backport] Move Pathname to core from stdlib ([#2730](https://github.com/ruby/rbs/pull/2730))
|
|
44
|
+
* Backport rdoc 6.16 ([#2722](https://github.com/ruby/rbs/pull/2722))
|
|
45
|
+
* Backport rdoc support ([#2719](https://github.com/ruby/rbs/pull/2719))
|
|
46
|
+
* Backport "Remove sig for IO#{ready?,nread}" ([#2720](https://github.com/ruby/rbs/pull/2720))
|
|
47
|
+
* Backport more pure C parsers ([#2679](https://github.com/ruby/rbs/pull/2679))
|
|
48
|
+
* Backport module name normalization ([#2673](https://github.com/ruby/rbs/pull/2673))
|
|
49
|
+
* Backport pure-C parser ([#2671](https://github.com/ruby/rbs/pull/2671))
|
|
50
|
+
* Fix test failure ([#2672](https://github.com/ruby/rbs/pull/2672))
|
|
51
|
+
|
|
3
52
|
## 3.9.5 (2025-09-08)
|
|
4
53
|
|
|
5
54
|
### Signature updates
|
data/README.md
CHANGED
|
@@ -141,7 +141,7 @@ require "rbs"
|
|
|
141
141
|
loader = RBS::EnvironmentLoader.new()
|
|
142
142
|
|
|
143
143
|
# loader.add(path: Pathname("sig")) # Load .rbs files from `sig` directory
|
|
144
|
-
# loader.add(library: "
|
|
144
|
+
# loader.add(library: "logger") # Load logger library
|
|
145
145
|
|
|
146
146
|
environment = RBS::Environment.from_loader(loader).resolve_type_names
|
|
147
147
|
|
|
@@ -198,6 +198,43 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
|
198
198
|
|
|
199
199
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
200
200
|
|
|
201
|
+
### C Code Formatting
|
|
202
|
+
|
|
203
|
+
This project uses `clang-format` to enforce consistent formatting of C code with a `.clang-format` configuration in the root directory.
|
|
204
|
+
|
|
205
|
+
#### Setup
|
|
206
|
+
|
|
207
|
+
First, install clang-format:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# macOS
|
|
211
|
+
brew install clang-format
|
|
212
|
+
|
|
213
|
+
# Ubuntu/Debian
|
|
214
|
+
sudo apt-get install clang-format
|
|
215
|
+
|
|
216
|
+
# Windows
|
|
217
|
+
choco install llvm
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
#### Usage
|
|
221
|
+
|
|
222
|
+
Format all C source files:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
rake format:c
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Check formatting without making changes:
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
rake format:c_check
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
#### Editor Integration
|
|
235
|
+
|
|
236
|
+
For VS Code users, install the "clangd" extension which will automatically use the project's `.clang-format` file.
|
|
237
|
+
|
|
201
238
|
## Contributing
|
|
202
239
|
|
|
203
240
|
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/rbs.
|
data/Rakefile
CHANGED
|
@@ -11,12 +11,26 @@ bin = File.join(__dir__, "bin")
|
|
|
11
11
|
|
|
12
12
|
Rake::ExtensionTask.new("rbs_extension")
|
|
13
13
|
|
|
14
|
+
compile_task = Rake::Task[:compile]
|
|
15
|
+
|
|
16
|
+
task :setup_extconf_compile_commands_json do
|
|
17
|
+
ENV["COMPILE_COMMANDS_JSON"] = "1"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
compile_task.prerequisites.unshift(:setup_extconf_compile_commands_json)
|
|
21
|
+
|
|
14
22
|
test_config = lambda do |t|
|
|
15
23
|
t.libs << "test"
|
|
16
24
|
t.libs << "lib"
|
|
17
25
|
t.test_files = FileList["test/**/*_test.rb"].reject do |path|
|
|
18
26
|
path =~ %r{test/stdlib/}
|
|
19
27
|
end
|
|
28
|
+
if defined?(RubyMemcheck)
|
|
29
|
+
if t.is_a?(RubyMemcheck::TestTask)
|
|
30
|
+
t.verbose = true
|
|
31
|
+
t.options = '-v'
|
|
32
|
+
end
|
|
33
|
+
end
|
|
20
34
|
end
|
|
21
35
|
|
|
22
36
|
Rake::TestTask.new(test: :compile, &test_config)
|
|
@@ -36,12 +50,13 @@ end
|
|
|
36
50
|
multitask :default => [:test, :stdlib_test, :typecheck_test, :rubocop, :validate, :test_doc]
|
|
37
51
|
|
|
38
52
|
task :lexer do
|
|
39
|
-
sh "re2c -W --no-generation-date -o
|
|
53
|
+
sh "re2c -W --no-generation-date -o src/lexer.c src/lexer.re"
|
|
54
|
+
sh "clang-format -i -style=file src/lexer.c"
|
|
40
55
|
end
|
|
41
56
|
|
|
42
57
|
task :confirm_lexer => :lexer do
|
|
43
58
|
puts "Testing if lexer.c is updated with respect to lexer.re"
|
|
44
|
-
sh "git diff --exit-code
|
|
59
|
+
sh "git diff --exit-code src/lexer.c"
|
|
45
60
|
end
|
|
46
61
|
|
|
47
62
|
task :confirm_templates => :templates do
|
|
@@ -49,6 +64,84 @@ task :confirm_templates => :templates do
|
|
|
49
64
|
sh "git diff --exit-code -- include src"
|
|
50
65
|
end
|
|
51
66
|
|
|
67
|
+
# Task to format C code using clang-format
|
|
68
|
+
namespace :format do
|
|
69
|
+
dirs = ["src", "ext", "include"]
|
|
70
|
+
|
|
71
|
+
# Find all C source and header files
|
|
72
|
+
files = `find #{dirs.join(" ")} -type f \\( -name "*.c" -o -name "*.h" \\)`.split("\n")
|
|
73
|
+
|
|
74
|
+
desc "Format C source files using clang-format"
|
|
75
|
+
task :c do
|
|
76
|
+
puts "Formatting C files..."
|
|
77
|
+
|
|
78
|
+
# Check if clang-format is installed
|
|
79
|
+
unless system("which clang-format > /dev/null 2>&1")
|
|
80
|
+
abort "Error: clang-format not found. Please install clang-format first."
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
if files.empty?
|
|
84
|
+
puts "No C files found to format"
|
|
85
|
+
next
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
puts "Found #{files.length} files to format (excluding generated files)"
|
|
89
|
+
|
|
90
|
+
exit_status = 0
|
|
91
|
+
files.each do |file|
|
|
92
|
+
puts "Formatting #{file}"
|
|
93
|
+
unless system("clang-format -i -style=file #{file}")
|
|
94
|
+
puts "❌ Error formatting #{file}"
|
|
95
|
+
exit_status = 1
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
exit exit_status unless exit_status == 0
|
|
100
|
+
puts "✅ All files formatted successfully"
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
desc "Check if C source files are properly formatted"
|
|
104
|
+
task :c_check do
|
|
105
|
+
puts "Checking C file formatting..."
|
|
106
|
+
|
|
107
|
+
# Check if clang-format is installed
|
|
108
|
+
unless system("which clang-format > /dev/null 2>&1")
|
|
109
|
+
abort "Error: clang-format not found. Please install clang-format first."
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
if files.empty?
|
|
113
|
+
puts "No C files found to check"
|
|
114
|
+
next
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
puts "Found #{files.length} files to check (excluding generated files)"
|
|
118
|
+
|
|
119
|
+
needs_format = false
|
|
120
|
+
files.each do |file|
|
|
121
|
+
formatted = `clang-format -style=file #{file}`
|
|
122
|
+
original = File.read(file)
|
|
123
|
+
|
|
124
|
+
if formatted != original
|
|
125
|
+
puts "❌ #{file} needs formatting"
|
|
126
|
+
puts "Diff:"
|
|
127
|
+
# Save formatted version to temp file and run diff
|
|
128
|
+
temp_file = "#{file}.formatted"
|
|
129
|
+
File.write(temp_file, formatted)
|
|
130
|
+
system("diff -u #{file} #{temp_file}")
|
|
131
|
+
File.unlink(temp_file)
|
|
132
|
+
needs_format = true
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
if needs_format
|
|
137
|
+
warn "Some files need formatting. Run 'rake format:c' to format them."
|
|
138
|
+
exit 1
|
|
139
|
+
else
|
|
140
|
+
puts "✅ All files are properly formatted"
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
52
145
|
rule ".c" => ".re" do |t|
|
|
53
146
|
puts "⚠️⚠️⚠️ #{t.name} is older than #{t.source}. You may need to run `rake lexer` ⚠️⚠️⚠️"
|
|
54
147
|
end
|
|
@@ -70,17 +163,22 @@ task :confirm_annotation do
|
|
|
70
163
|
end
|
|
71
164
|
|
|
72
165
|
task :templates do
|
|
73
|
-
sh "#{ruby} templates/template.rb
|
|
74
|
-
sh "#{ruby} templates/template.rb
|
|
75
|
-
|
|
76
|
-
sh "#{ruby} templates/template.rb
|
|
166
|
+
sh "#{ruby} templates/template.rb ext/rbs_extension/ast_translation.h"
|
|
167
|
+
sh "#{ruby} templates/template.rb ext/rbs_extension/ast_translation.c"
|
|
168
|
+
|
|
169
|
+
sh "#{ruby} templates/template.rb ext/rbs_extension/class_constants.h"
|
|
170
|
+
sh "#{ruby} templates/template.rb ext/rbs_extension/class_constants.c"
|
|
171
|
+
|
|
172
|
+
sh "#{ruby} templates/template.rb include/rbs/ast.h"
|
|
173
|
+
sh "#{ruby} templates/template.rb src/ast.c"
|
|
174
|
+
|
|
175
|
+
# Format the generated files
|
|
176
|
+
Rake::Task["format:c"].invoke
|
|
77
177
|
end
|
|
78
178
|
|
|
79
|
-
task :compile => "ext/rbs_extension/
|
|
80
|
-
task :compile => "
|
|
81
|
-
task :compile => "
|
|
82
|
-
task :compile => "src/constants.c"
|
|
83
|
-
task :compile => "src/ruby_objs.c"
|
|
179
|
+
task :compile => "ext/rbs_extension/class_constants.h"
|
|
180
|
+
task :compile => "ext/rbs_extension/class_constants.c"
|
|
181
|
+
task :compile => "src/lexer.c"
|
|
84
182
|
|
|
85
183
|
task :test_doc do
|
|
86
184
|
files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
@@ -114,7 +212,14 @@ task :validate => :compile do
|
|
|
114
212
|
end
|
|
115
213
|
|
|
116
214
|
libs.each do |lib|
|
|
117
|
-
|
|
215
|
+
args = ["-r", lib]
|
|
216
|
+
|
|
217
|
+
if lib == "rbs"
|
|
218
|
+
args << "-r"
|
|
219
|
+
args << "prism"
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
sh "#{ruby} #{rbs} #{args.join(' ')} validate --exit-error-on-syntax-error"
|
|
118
223
|
end
|
|
119
224
|
end
|
|
120
225
|
|
|
@@ -126,7 +231,7 @@ end
|
|
|
126
231
|
|
|
127
232
|
task :stdlib_test => :compile do
|
|
128
233
|
test_files = FileList["test/stdlib/**/*_test.rb"].reject do |path|
|
|
129
|
-
path =~ %r{Ractor} || path =~ %r{Encoding} || path =~ %r{
|
|
234
|
+
path =~ %r{Ractor} || path =~ %r{Encoding} || path =~ %r{CGI-escape_test}
|
|
130
235
|
end
|
|
131
236
|
|
|
132
237
|
if ENV["RANDOMIZE_STDLIB_TEST_ORDER"] == "true"
|
|
@@ -135,19 +240,21 @@ task :stdlib_test => :compile do
|
|
|
135
240
|
|
|
136
241
|
sh "#{ruby} -Ilib #{bin}/test_runner.rb #{test_files.join(' ')}"
|
|
137
242
|
# TODO: Ractor tests need to be run in a separate process
|
|
138
|
-
sh "#{ruby} -Ilib #{bin}/test_runner.rb test/stdlib/
|
|
243
|
+
sh "#{ruby} -Ilib #{bin}/test_runner.rb test/stdlib/CGI-escape_test.rb"
|
|
139
244
|
sh "#{ruby} -Ilib #{bin}/test_runner.rb test/stdlib/Ractor_test.rb"
|
|
140
245
|
sh "#{ruby} -Ilib #{bin}/test_runner.rb test/stdlib/Encoding_test.rb"
|
|
141
246
|
end
|
|
142
247
|
|
|
143
248
|
task :typecheck_test => :compile do
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
249
|
+
Bundler.with_unbundled_env do
|
|
250
|
+
FileList["test/typecheck/*"].each do |test|
|
|
251
|
+
Dir.chdir(test) do
|
|
252
|
+
expectations = File.join(test, "steep_expectations.yml")
|
|
253
|
+
if File.exist?(expectations)
|
|
254
|
+
sh "#{__dir__}/bin/steep check --with_expectations"
|
|
255
|
+
else
|
|
256
|
+
sh "#{__dir__}/bin/steep check"
|
|
257
|
+
end
|
|
151
258
|
end
|
|
152
259
|
end
|
|
153
260
|
end
|
|
@@ -228,7 +335,7 @@ namespace :generate do
|
|
|
228
335
|
class <%= target %>SingletonTest < Test::Unit::TestCase
|
|
229
336
|
include TestHelper
|
|
230
337
|
|
|
231
|
-
# library "
|
|
338
|
+
# library "logger", "securerandom" # Declare library signatures to load
|
|
232
339
|
testing "singleton(::<%= target %>)"
|
|
233
340
|
|
|
234
341
|
<%- class_methods.each do |method_name, definition| -%>
|
|
@@ -247,7 +354,7 @@ namespace :generate do
|
|
|
247
354
|
class <%= target %>Test < Test::Unit::TestCase
|
|
248
355
|
include TestHelper
|
|
249
356
|
|
|
250
|
-
# library "
|
|
357
|
+
# library "logger", "securerandom" # Declare library signatures to load
|
|
251
358
|
testing "::<%= target %>"
|
|
252
359
|
|
|
253
360
|
<%- instance_methods.each do |method_name, definition| -%>
|
|
@@ -430,3 +537,25 @@ task :changelog do
|
|
|
430
537
|
puts " (🤑 There is no *unreleased* pull request associated to the milestone.)"
|
|
431
538
|
end
|
|
432
539
|
end
|
|
540
|
+
|
|
541
|
+
desc "Compile extension without C23 extensions"
|
|
542
|
+
task :compile_c99 do
|
|
543
|
+
ENV["TEST_NO_C23"] = "true"
|
|
544
|
+
Rake::Task[:"compile"].invoke
|
|
545
|
+
ensure
|
|
546
|
+
ENV.delete("TEST_NO_C23")
|
|
547
|
+
end
|
|
548
|
+
|
|
549
|
+
task :prepare_bench do
|
|
550
|
+
ENV.delete("DEBUG")
|
|
551
|
+
Rake::Task[:"clobber"].invoke
|
|
552
|
+
Rake::Task[:"templates"].invoke
|
|
553
|
+
Rake::Task[:"compile"].invoke
|
|
554
|
+
end
|
|
555
|
+
|
|
556
|
+
task :prepare_profiling do
|
|
557
|
+
ENV["DEBUG"] = "1"
|
|
558
|
+
Rake::Task[:"clobber"].invoke
|
|
559
|
+
Rake::Task[:"templates"].invoke
|
|
560
|
+
Rake::Task[:"compile"].invoke
|
|
561
|
+
end
|