ml.ruby-lang.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

ruby-core

Thread Start a new thread
Download
Threads by month
  • ----- 2025 -----
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
ruby-core@ml.ruby-lang.org

December 2022

  • 10 participants
  • 244 discussions
[ruby-core:111210] [Ruby master Bug#19184] create a Range with String subclass presents a weird behavior
by clavius_tales (Clavius Tales Rocha Moreira) 05 Dec '22

05 Dec '22
Issue #19184 has been reported by clavius_tales (Clavius Tales Rocha Moreira). ---------------------------------------- Bug #19184: create a Range with String subclass presents a weird behavior https://bugs.ruby-lang.org/issues/19184 * Author: clavius_tales (Clavius Tales Rocha Moreira) * Status: Open * Priority: Normal * ruby -v: 3.1.3 * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- ``` ruby class CalendarMonth < String def succ self.class.new( if december? "#{year + 1}-01" else "#{year}-#{(month + 1).to_s.rjust(2, '0')}" end ) end private def december? month == 12 end def month self[-2..].to_i end def year self[0..3].to_i end end (CalendarMonth.new('2021-11')..CalendarMonth.new('2022-02')).to_a ``` Running the script above in Ruby 2.7.5, we get: ``` ruby ["2021-11", "2021-12", "2022-01", "2022-02"] ``` Running the same script in Ruby 3.1.3: ```ruby ["2021-11", "2021-12", "2021-13", "2021-14", "2021-15", "2021-16", "2021-17", "2021-18", "2021-19", "2021-20", "2021-21", "2021-22", "2021-23", "2021-24", "2021-25", "2021-26", "2021-27", "2021-28", "2021-29", "2021-30", "2021-31", "2021-32", "2021-33", "2021-34", "2021-35", "2021-36", "2021-37", "2021-38", "2021-39", "2021-40", "2021-41", "2021-42", "2021-43", "2021-44", "2021-45", "2021-46", "2021-47", "2021-48", "2021-49", "2021-50", "2021-51", "2021-52", "2021-53", "2021-54", "2021-55", "2021-56", "2021-57", "2021-58", "2021-59", "2021-60", "2021-61", "2021-62", "2021-63", "2021-64", "2021-65", "2021-66", "2021-67", "2021-68", "2021-69", "2021-70", "2021-71", "2021-72", "2021-73", "2021-74", "2021-75", "2021-76", "2021-77", "2021-78", "2021-79", "2021-80", "2021-81", "2021-82", "2021-83", "2021-84", "2021-85", "2021-86", "2021-87", "2021-88", "2021-89", "2021-90", "2021-91", "2021-92", "2021-93", "2021-94", "2021-95", "2021-96", "2021-97", "2021-98", "2021-99", "2022-00", "2022-01", "2022-02"] ``` I know it's not a good modeling inherit from String class, but... -- https://bugs.ruby-lang.org/
2 2
0 0
[ruby-core:111209] [Ruby master Bug#19115] RubyGems fails to detect OpenSSL in --with-static-linked-ext builds
by thomthom (Thomas Thomassen) 05 Dec '22

05 Dec '22
Issue #19115 has been updated by thomthom (Thomas Thomassen). Will this patch be pack-ported to the 3.1 branch? ---------------------------------------- Bug #19115: RubyGems fails to detect OpenSSL in --with-static-linked-ext builds https://bugs.ruby-lang.org/issues/19115#change-100500 * Author: thomthom (Thomas Thomassen) * Status: Closed * Priority: Normal * ruby -v: 3.1.2, 3.2.0dev * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- Related discussion: https://bugs.ruby-lang.org/issues/18876 We are seeing OpenSSL failing to autoload with the Ruby build we've been using. (We first observed this when using `Gem.install` that relies on autoload of OpenSSL). Our last working build was Ruby 2.7.2 with similar config. This causes RubyGems' `HAVE_OPENSSL` constant to be incorrectly initialized, and subsequent calls to `Gem.install` fails. There might be other scenarios that fail as a result of that, but we've not managed to identified that. ``` module Gem HAVE_OPENSSL = defined? OpenSSL::SSL # :nodoc: ``` Our Ruby 3.1.2 config: ``` '--prefix=/Users/user/.conan/data/ruby/3.1.2/sketchup/stable/build/bd95825b99dcb274d0e577fbdc953653a9ea0fb9' '--with-openssl-dir=/Users/user/.conan/data/openssl/1.1.1q/sketchup/stable/package/93ae0b0e7eebe0611c04d3e0d9bbf49fbce92332' '--with-libyaml-dir=/Users/user/.conan/data/libyaml/0.2.5/sketchup/stable/package/a56a950abed2e10dbdc26845400f0a034d97c454' '--disable-install-doc' '--disable-install-rdoc' '--enable-shared' '--enable-load-relative' '--with-static-linked-ext' '--without-debug' '--without-gdbm' '--without-gettext' '--without-irb' '--without-mkmf' '--without-rdoc' '--without-readline' '--without-tk' '--bindir=${prefix}/bin' '--sbindir=${prefix}/bin' '--libexecdir=${prefix}/bin' '--libdir=${prefix}/lib' '--includedir=${prefix}/include' '--oldincludedir=${prefix}/include' '--datarootdir=${prefix}/share' 'cflags=-mmacosx-version-min=10.14 -fdeclspec' 'cxxflags=-mmacosx-version-min=10.14 -fdeclspec' 'LDFLAGS=-mmacosx-version-min=10.14 -fdeclspec' ``` We also tested with latest build from master (November 8th 2022): ``` ./ruby -ve 'p RbConfig::CONFIG["configure_args"]' ruby 3.2.0dev (2022-11-07T19:35:21Z master b14f133054) [x86_64-darwin20] " '--prefix=/Users/vmehta/ruby/ruby-master/' '--with-openssl-dir=/Users/vmehta/.conan/data/openssl/1.1.1q/sketchup/stable/package/f2d937af1fa19d5fc4095849a65d1927e9e75ae7/' '--with-libyaml-dir=/Users/vmehta/.conan/data/libyaml/0.2.5/sketchup/stable/package/3fc084e254210603a5c5aece184b2d45e2509b30' '--disable-install-doc' '--disable-install-rdoc' '--enable-shared' '--enable-load-relative' '--with-static-linked-ext' '--without-debug' '--without-gdbm' '--without-gettext' '--without-irb' '--without-mkmf' '--without-rdoc' '--without-readline' '--without-tk'" ``` Using an RVM of Ruby 3.1.2 this appear to work as expected. But using out configuration, that we've used for the Ruby 2.x versions are now failing. We haven't been able to figure out the reason for this. -- https://bugs.ruby-lang.org/
1 0
0 0
[ruby-core:111208] [Ruby master Feature#19183] Add bin/goruby, bin/ruby, and lib/libruby.so.3.2.0 (or similar) to .gitignore
by duerst 05 Dec '22

05 Dec '22
Issue #19183 has been reported by duerst (Martin Dürst). ---------------------------------------- Feature #19183: Add bin/goruby, bin/ruby, and lib/libruby.so.3.2.0 (or similar) to .gitignore https://bugs.ruby-lang.org/issues/19183 * Author: duerst (Martin Dürst) * Status: Open * Priority: Normal ---------------------------------------- When I compile ruby, and then use `git status`, the files `bin/goruby`, `bin/ruby`, and `lib/libruby.so.3.2.0` (or similar) always show up as untracked files. I think they should be added to .gitignore. -- https://bugs.ruby-lang.org/
1 0
0 0
[ruby-core:111181] [Ruby master Feature#19177] optional offset for Array#index
by Dan0042 (Daniel DeLorme) 05 Dec '22

05 Dec '22
Issue #19177 has been reported by Dan0042 (Daniel DeLorme). ---------------------------------------- Feature #19177: optional offset for Array#index https://bugs.ruby-lang.org/issues/19177 * Author: Dan0042 (Daniel DeLorme) * Status: Open * Priority: Normal ---------------------------------------- String#index allows an optional offset: ```ruby "the quick brown fox jumps over the lazy dog".index("the") #=> 0 "the quick brown fox jumps over the lazy dog".index("the",1) #=> 31 ``` I was a bit surprised that Array doesn't support this and I feel it would be a very natural addition: ```ruby %w[the quick brown fox jumps over the lazy dog].index("the") #=> 0 %w[the quick brown fox jumps over the lazy dog].index("the",1) #=> 6 instead of ArgumentError ``` -- https://bugs.ruby-lang.org/
2 2
0 0
[ruby-core:111206] [Ruby master Feature#16122] Data: simple immutable value object
by matz (Yukihiro Matsumoto) 05 Dec '22

05 Dec '22
Issue #16122 has been updated by matz (Yukihiro Matsumoto). I propose a little bit different approach: ```ruby Ticket = Data.define(:event_id, :user_id,:start_at) do # And other methods defined below def validate puts "Validated!" end end ``` This is much consistent and work now without any enhancement. Matz. ---------------------------------------- Feature #16122: Data: simple immutable value object https://bugs.ruby-lang.org/issues/16122#change-100496 * Author: zverok (Victor Shepelev) * Status: Closed * Priority: Normal * Assignee: zverok (Victor Shepelev) ---------------------------------------- ## Intro (original theoretical part of the proposal) **Value Object** is a useful concept, introduced by Martin Fowler ([his post](https://martinfowler.com/bliki/ValueObject.html), [Wikipedia Entry](https://en.wikipedia.org/wiki/Value_object)) with the following properties (simplifying the idea): * representing some relatively simple data; * immutable; * compared by type & value; * nicely represented. Value objects are super-useful especially for defining APIs, their input/return values. Recently, there were some movement towards using more immutability-friendly approach in Ruby programming, leading to creating several discussions/libraries with value objects. For example, [Tom Dalling's gem](https://github.com/tomdalling/value_semantics), [Good Ruby Value object convention](https://github.com/zverok/good-value-object) (disclaimer: the latter is maintained by yours truly). I propose to introduce **native value objects** to Ruby as a core class. **Why not a gem?** * I believe that concept is that simple, that nobody *will even try* to use a gem for representing it with, unless the framework/library used already provides one. * Potentially, a lot of standard library (and probably even core) APIs could benefit from the concept. **Why `Struct` is not enough** Core `Struct` class is "somewhat alike" value-object, and frequently used instead of one: it is compared by value and consists of simple attributes. On the other hand, `Struct` is: * mutable; * collection-alike (defines `to_a` and is `Enumerable`); * dictionary-alike (has `[]` and `.values` methods). The above traits somehow erodes the semantics, making code less clear, especially when duck-typing is used. For example, this code snippet shows why `to_a` is problematic: ```ruby Result = Struct.new(:success, :content) # Now, imagine that other code assumes `data` could be either Result, or [Result, Result, Result] # So, ... data = Result.new(true, 'it is awesome') Array(data) # => expected [Result(true, 'it is awesome')], got [true, 'it is awesome'] # or... def foo(arg1, arg2 = nil) p arg1, arg2 end foo(*data) # => expected [Result(true, 'it is awesome'), nil], got [true, 'it is awesome'] ``` Having `[]` and `each` defined on something that is thought as "just value" can also lead to subtle bugs, when some method checks "if the received argument is collection-alike", and value object's author doesn't thought of it as a collection. ## `Data` class: consensus proposal/implementation, Sep 2022 * Name: `Data` * PR: https://github.com/ruby/ruby/pull/6353 * Example docs rendering: https://zverok.space/ruby-rdoc/Data.html * Full API: * `Data::define` creates a new Data class; accepts only symbols (no `keyword_init:`, no "first argument is the class name" like the `Struct` had) * `<data_class>::members`: list of member names * `<data_class>::new`: accepts either keyword or positional arguments (but not mix); converts all of the to keyword args; raises `ArgumentError` if there are **too many positional arguments** * `#initialize`: accepts only keyword arguments; the default implementation raises `ArgumentError` on missing or extra arguments; it is easy to redefine `initialize` to provide defaults or handle extra args. * `#==` * `#eql?` * `#inspect`/`#to_s` (same representation) * `#deconstruct` * `#deconstruct_keys` * `#hash` * `#members` * `#to_h` ## Historical original proposal * Class name: `Struct::Value`: lot of Rubyists are used to have `Struct` as a quick "something-like-value" drop-in, so alternative, more strict implementation, being part of `Struct` API, will be quite discoverable; *alternative: just `Value`* * Class API is copying `Struct`s one (most of the time -- even reuses the implementation), with the following exceptions *(note: the immutability is **not** the only difference)*: * Not `Enumerable`; * Immutable; * Doesn't think of itself as "almost hash" (doesn't have `to_a`, `values` and `[]` methods); * Can have empty members list (fun fact: `Struct.new('Foo')` creating member-less `Struct::Foo`, is allowed, but `Struct.new()` is not) to allow usage patterns like: ```ruby class MyService Success = Struct::Value.new(:results) NotFound = Struct::Value.new end ``` `NotFound` here, unlike, say, `Object.new.freeze` (another pattern for creating "empty typed value object"), has nice inspect `#<value NotFound>`, and created consistently with the `Success`, making the code more readable. And if it will evolve to have some attributes, the code change would be easy. **Patch is provided** [Sample rendered RDoc documentation](https://zverok.github.io/ruby-rdoc/Struct-Value.html) ---Files-------------------------------- struct_value.patch (18.6 KB) -- https://bugs.ruby-lang.org/
1 0
0 0
[ruby-core:111205] [Ruby master Bug#19182] ALWAYS_UPDATE_UNICODE=yes downloads all the Unicode files twice when executing make
by duerst 05 Dec '22

05 Dec '22
Issue #19182 has been reported by duerst (Martin Dürst). ---------------------------------------- Bug #19182: ALWAYS_UPDATE_UNICODE=yes downloads all the Unicode files twice when executing make https://bugs.ruby-lang.org/issues/19182 * Author: duerst (Martin Dürst) * Status: Open * Priority: Normal * Assignee: nobu (Nobuyoshi Nakada) * ruby -v: ruby 3.2.0dev (2022-12-04T20:23:09Z master d90835aeb5) [x86_64-linux] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- `make` downloads all the Unicode files twice when ALWAYS_UPDATE_UNICODE is set to yes. One download is for miniruby, the second is for ruby. This shouldn't be necessary. I hope this can be fixed. -- https://bugs.ruby-lang.org/
1 0
0 0
[ruby-core:111204] [Ruby master Bug#19181] lib/unicode-normalize/tables.rb does not get updated even if ALWAYS_UPDATE_UNICODE is set to yes
by duerst 05 Dec '22

05 Dec '22
Issue #19181 has been reported by duerst (Martin Dürst). ---------------------------------------- Bug #19181: lib/unicode-normalize/tables.rb does not get updated even if ALWAYS_UPDATE_UNICODE is set to yes https://bugs.ruby-lang.org/issues/19181 * Author: duerst (Martin Dürst) * Status: Open * Priority: Normal * Assignee: nobu (Nobuyoshi Nakada) * ruby -v: ruby 3.2.0dev (2022-12-04T20:23:09Z master d90835aeb5) [x86_64-linux] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- To update lib/unicode-normalize/tables.rb to Unicode version 15.0.0, I had to manually remove this file. This should not be necessary. Also, it should not be necessary to have to set ALWAYS_UPDATE_UNICODE to yes just to update this file. -- https://bugs.ruby-lang.org/
1 0
0 0
[ruby-core:111203] [Ruby master Bug#19180] rbconfig.rb does not get updated when common.mk is changed
by duerst 05 Dec '22

05 Dec '22
Issue #19180 has been reported by duerst (Martin Dürst). ---------------------------------------- Bug #19180: rbconfig.rb does not get updated when common.mk is changed https://bugs.ruby-lang.org/issues/19180 * Author: duerst (Martin Dürst) * Status: Open * Priority: Normal * Assignee: nobu (Nobuyoshi Nakada) * ruby -v: ruby 3.1.0dev (2021-06-03T06:59:33Z master 7e14762159) [x86_64-linux] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- I changed UNICODE_VERSION in common.mk to 15.0.0, and ran `make up`, `make`, `make runnable`, and various tests several times. Still rbconfig.rb, and therefore `RbConfig::CONFIG["UNICODE_VERSION"]`, says that the Unicode version is 14.0.0. There seems to be a missing dependency of rbconfig.rb on common.mk somewhere in the makefiles, please add such a dependency. -- https://bugs.ruby-lang.org/
1 0
0 0
[ruby-core:111202] [Ruby master Bug#18623] `make runnable` does not work
by duerst 04 Dec '22

04 Dec '22
Issue #18623 has been updated by duerst (Martin Dürst). @nakada: I again hit this. I found out that the solution is easy, just do `make goruby` before using `make runnable`. I propose to add `goruby` to the targets necessary when creating `runnable`, to avoid additional steps and unnecessary confusion. ---------------------------------------- Bug #18623: `make runnable` does not work https://bugs.ruby-lang.org/issues/18623#change-100494 * Author: duerst (Martin Dürst) * Status: Open * Priority: Normal * Assignee: nobu (Nobuyoshi Nakada) * ruby -v: ruby 3.1.0dev (2021-06-03T06:59:33Z master 7e14762159) [x86_64-linux] * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- When I try `make runnable` to be able to run individual tests with `.\ruby test/runner.rb ...`, I get the error below. It is important to solve this so I can make progress on Feature #18037. Except for the problem reported at Bug #18614, comprehensive tests such as `make check` work fine. ``` duerst@Kloentalersee:~/14ruby$ make runnable BASERUBY = /usr/local/bin/ruby --disable=gems CC = gcc LD = ld LDSHARED = gcc -shared CFLAGS = -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Werror=deprecated-declarations -Werror=div-by-zero -Werror=duplicated-cond -Werror=implicit-function-declaration -Werror=implicit-int -Werror=misleading-indentation -Werror=pointer-arith -Werror=write-strings -Werror=old-style-definition -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Werror=undef -std=gnu99 XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-strict-overflow -DRUBY_DEVEL=1 -fvisibility=hidden -fexcess-precision=standard -DRUBY_EXPORT -fPIE -I. -I.ext/include/x86_64-linux -I./include -I. -I./enc/unicode/14.0.0 CPPFLAGS = DLDFLAGS = -Wl,--compress-debug-sections=zlib -fstack-protector-strong -pie SOLIBS = -lz -lpthread -lrt -lrt -lgmp -ldl -lcrypt -lm LANG = C.UTF-8 LC_ALL = LC_CTYPE = MFLAGS = gcc (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ln -f goruby ./bin/goruby /home/duerst/14ruby/lib/fileutils.rb:301:in `link': No such file or directory @ rb_file_s_link - (goruby, ./bin/goruby) (Errno::ENOENT) from /home/duerst/14ruby/lib/fileutils.rb:301:in `block in ln' from /home/duerst/14ruby/lib/fileutils.rb:1593:in `fu_each_src_dest0' from /home/duerst/14ruby/lib/fileutils.rb:299:in `ln' from /home/duerst/14ruby/lib/fileutils.rb:1695:in `ln' from ./tool/mkrunnable.rb:59:in `ln_exe' from ./tool/mkrunnable.rb:96:in `ln_relative' from ./tool/mkrunnable.rb:131:in `block in <main>' from ./tool/mkrunnable.rb:128:in `map' from ./tool/mkrunnable.rb:128:in `<main>' make: *** [uncommon.mk:872: runnable] Error 1 duerst@Kloentalersee:~/14ruby$ ``` -- https://bugs.ruby-lang.org/
1 0
0 0
[ruby-core:111201] [Ruby master Feature#10343] Postfix notations for `when` and `else` inside `case` statement
by sawa (Tsuyoshi Sawada) 04 Dec '22

04 Dec '22
Issue #10343 has been updated by sawa (Tsuyoshi Sawada). After eight years, I still think this would be a good feature. Any opinions? ---------------------------------------- Feature #10343: Postfix notations for `when` and `else` inside `case` statement https://bugs.ruby-lang.org/issues/10343#change-100492 * Author: sawa (Tsuyoshi Sawada) * Status: Open * Priority: Normal ---------------------------------------- In a `case` statement, the condition part in the branches do not have the same length in general, and especially, `else` is much shorter than the conditions (`when ...`). So when we write the condition and the return value in a single line, they are not aligned, and are hard to read. ```ruby case foo when some_very_long_condition then "a" when short_cond then "bb" when some_long_condition then "ccc" else "dddd" end ``` I propose to allow postfix notations with `when` and `else` (or `otherwise`) inside `case` statement as below: ```ruby case foo "a" when some_very_long_proc "bb" when short_regex "ccc" when some_long_regex "dddd" else end ``` Pros are: 1) Postfix notation does not require `then` or `;`, so it is concise. 2) The return values from the branches (e.g., `"a"`, `"bb"`, `"ccc"`, `"dddd"`) tend to be shorter and more uniformly lengthened than the conditions, hence they are somewhat close to being aligned naturally, making this easier to read. 3) We are usually more interested in the return value than the condition of a branch, especially when we are reading someone's code and are trying to grasp what the `case` statement does or returns. 4) This notation is closer to case-like conditional notations regularly used in mathematics: ``` ┌ 1 (x = 0) x! = │ └ x (x - 1)! (otherwise) ``` So it would be easier to read for those who are familiar with mathematics. -- https://bugs.ruby-lang.org/
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • ...
  • 25
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.