Repository navigation
Replace the Ruby 1.9 library tree with Ruby 4.0 implementations - #30
Merged
Merged
Conversation
Rational and Complex are now Ruby ports of CRuby 4.0's rational.c and complex.c (Src/StdLib/ironruby/ironruby/rational.rb, complex.rb), with the methods those files define on Integer, Float, Numeric, String and Kernel and the Rational/Complex branches of numeric.c's Integer#** and Float#**. They replace complex18.rb/rational18.rb and the ~1,400 lines of ruby4.rb that patched their 1.8 behaviour, along with the C# autoload hack (ObjectOps ___Numerics__), the Kernel#Complex/#Rational stubs, Integer#quo returning a Float, and the C# Integer#to_r/String#to_r. Fixnum + and * hand a Complex operand to Complex#+/#* as numeric.c does. Pathname is CRuby 4.0's pathname_builtin.rb (autoloaded) plus lib/pathname.rb (find, rmtree, mktmpdir), loaded by `require "pathname"`: the loader now lets a .rb found on the path through when only "foo.so" is in $", as MRI's search_required does. Everything else still reached in ruby/1.9.1 gets a 4.0 version under ironruby/: digest/sha2, json/add/* and json/generic_object (plus JSON.create_id), json/common|ext|version, ripper/filter and ripper/core| lexer|sexp, bigdecimal/math|jacobian|ludcmp|newton from bigdecimal 4.0.1 (with BigDecimal::Internal, #_decimal_shift, #n_significant_digits, Integer divisors for BigDecimal#/ and BigDecimal.limit(nil)), kconv from nkf 0.2.0 (NKF's codes are now Encodings), openssl/digest and openssl/x509. The rest of the tree is libraries Ruby 4.0 no longer has. ruby/1.9.1 is deleted and dropped from ir.sh, ir.cmd, the AOT tools, irubyc bundles, the default load path, RubyGems' stdlib dirs, default.mspec and CI. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KPwZf3xeDNiCfR2W334Av9
|
Important Review skippedToo many files! This PR contains 234 files, which is 134 over the limit of 100. To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.
|
…anup master trimmed ruby/1.9.1 to 160 files; this branch removes the directory, so the deletions stand. kconv.rb keeps nkf 0.2.0's verbatim copy: NKF's codes are Encodings here, which master's copy worked around by naming them itself. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KPwZf3xeDNiCfR2W334Av9
Largo
pushed a commit
that referenced
this pull request
Nov 7, 2026
Review finding (SHOULD, regression from b6a93b6): GetClrPatternSource/DecodeByteEscapes decoded \xHH runs inside (?#...) groups and /x line comments, so `Regexp.new("a(?#\\xff)b") =~ "ab"` and `Regexp.new("a # \\xff\nb", Regexp::EXTENDED) =~ "ab"` raised RegexpError, and the literals /a#\xff/x and /a(?#\xff)/ were SyntaxErrors at parse time (the literal path builds the same RubyRegex). Reproduced with review/bi2/cm.rb and review/bi2/re1.rb #29/#30 against CRuby 4.0.9. The decoder now steps over comments as Onigmo reads them: a (?#...) group up to the first unescaped ")", and in extended mode - /x, or (?x) / (?x:...) for the rest of a group - a # up to the end of the line outside a character class. RegexpTransformer's (?#...) skips an escaped ")" too, as Onigmo does (`Regexp.new("a(?#\\)\\xff)b") =~ "ab"` is 0 in CRuby; it was "unmatched close parenthesis" here). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KPwZf4gAJD4kdk9eEzGgYM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes
Src/StdLib/ruby/1.9.1entirely. Everything in it that was still reached at runtime now comes from Ruby 4.0 sources.Changes
Rational and Complex are Ruby ports of CRuby 4.0's
rational.candcomplex.c(Src/StdLib/ironruby/ironruby/rational.rb,complex.rb). They include the methods those files define on Integer, Float, Numeric, String and Kernel, plus the Rational/Complex branches of numeric.c'sInteger#**andFloat#**. This replacescomplex18.rb/rational18.rband removes:ruby4.rbObjectOps.___Numerics__) and theKernel#Complex/#RationalstubsInteger#quo(which returned a Float),Integer#to_randString#to_rFixnum
+/*now hand a Complex operand toComplex#+/#*as numeric.c does, so7 * Complex(1/2r, 3)gives((7/2)+21i).Pathname is CRuby 4.0's
pathname_builtin.rb(autoloaded), pluslib/pathname.rb(find,rmtree,mktmpdir), whichrequire "pathname"loads. The loader now loads afoo.rbit finds even when onlyfoo.sois in$", as MRI'ssearch_requireddoes.ironruby/enumerator.rbis deleted: it loaded an empty assembly and would otherwise have started being loaded.Other files still reached now have 4.0 versions under
ironruby/:digest/sha2,json/add/*,json/generic_object,ripper/filterJSON.create_id/create_id=added tojson.rbjson/common|ext|version,ripper/core|lexer|sexp,openssl/digest,openssl/x509bigdecimal/math|jacobian|ludcmp|newtonfrom bigdecimal 4.0.1. This neededBigDecimal::Internal,#_decimal_shift,#n_significant_digits, and two C# fixes:BigDecimal / Integerreturned a Float, andBigDecimal.limit(nil)raised.kconvfrom nkf 0.2.0;NKF's constants are now Encodings, as in nkf 0.2.0Dropped: the rest of the tree is libraries Ruby 4.0 doesn't have (cgi pieces,
date/delta,digest/hmac, old irb files,psych/deprecated, dl, syck, shell, xmlrpc, mathn, …). The oldwin32/resolv/win32/registryneeded DL, which IronRuby never had, so they already failed on Windows.References removed from
ir.sh,ir.cmd, the native-AOT tools, irubyc bundles (ALWAYS_COPIEDis now justironruby), the C# default load path, RubyGems' stdlib dirs,default.mspec, the CI parse sweep and the default gemspecs.Left alone:
site_ruby/1.9.1(rb-readline) is a separate folder.RbConfig::CONFIG["ruby_version"]stays"1.9.1"because it names that folder.Verification
Compared against a build of
master(d8088c6a), ruby/specdda28d04, mspecb79c65ed, net8.0:ruby_exepasses IronRuby's-X:flags)fixnum_max/fixnum_minhelpers, which have no case for IronRuby. CRuby passes those examples.TCPSocket.opentimeout examples that show up as new in the library sweep give 6 errors on both builds when that directory is rerun alone. The host refuses the connection instead of timing out.Comparison with CRuby 4.0.9
CRuby 4.0.9 was built from the
ruby_4_0branch (9bcca300), with bigdecimal 4.0.1 and nkf 0.2.0.mastermatched 5,205 and this PR matches 5,356. No expression that matched before stops matching. The 43 that still differ predate this PR:Integer#fdiv(Complex): the C# fdiv returns a Complex where CRuby raises RangeError.Math.hypotlast-digit precision, seen throughComplex#abs/#**.Integer/Rational/Complex ** Bignummatch exactly, includingArgumentError: exponent is too largeand theb may be too bigwarning.BigMath,LUSolveand_decimal_shiftprobes (26 values) and theRipper::Filteroutput.pathname_builtin.rbappears in$". The old 1.9pathname.rbdid too.json/addto_json: matches exceptBigDecimal(_dumpprecision 9 vs 18) andDate/DateTime(Date#startis2299161rather than2299161.0). Both are older C# issues; before this PRjson/add/coreraised NoMethodError.Kconv.guesson Shift_JIS bytes (Windows-31J vs Shift_JIS), which comes from nkf.rb's guess logic.Known gaps, not addressed here
to_json, andcreate_additions:is unimplemented. SoJSON.generate(1..3)still gives"1..3", although(1..3).to_jsonmatches CRuby.Integer#fdiv(Complex)returns a Complex where CRuby raises RangeError.Math.hypotis off in the last digit.Kconv.guessanswers Windows-31J for Shift_JIS.BigDecimal("1")/3keeps 18 digits where CRuby keeps 32.BigDecimal#_dumpreports precision 9 where CRuby reports 18.Date#startreturns an Integer instead of a Float.🤖 Generated with Claude Code
https://claude.ai/code/session_01KPwZf3xeDNiCfR2W334Av9