[#117021] [Ruby master Feature#20318] Pattern matching `case ... in` support for triple-dot arguments — "bradgessler (Brad Gessler) via ruby-core" <ruby-core@...>

Issue #20318 has been reported by bradgessler (Brad Gessler).

11 messages 2024/03/01

[#117027] [Ruby master Bug#20319] Singleton class is being frozen lazily in some cases — "andrykonchin (Andrew Konchin) via ruby-core" <ruby-core@...>

Issue #20319 has been reported by andrykonchin (Andrew Konchin).

8 messages 2024/03/01

[#117036] [Ruby master Bug#20321] `require': cannot load such file — "Justman10000 (Justin Nogossek) via ruby-core" <ruby-core@...>

Issue #20321 has been reported by Justman10000 (Justin Nogossek).

14 messages 2024/03/01

[#117067] [Ruby master Feature#20326] Add an `undefined` for use as a default argument. — "shan (Shannon Skipper) via ruby-core" <ruby-core@...>

Issue #20326 has been reported by shan (Shannon Skipper).

7 messages 2024/03/06

[#117115] [Ruby master Feature#20331] Should parser warn hash duplication and when clause? — "yui-knk (Kaneko Yuichiro) via ruby-core" <ruby-core@...>

Issue #20331 has been reported by yui-knk (Kaneko Yuichiro).

11 messages 2024/03/12

[#117147] [Ruby master Feature#20335] `Thread.each_caller_location` should accept the same arguments as `caller` and `caller_locations` — "byroot (Jean Boussier) via ruby-core" <ruby-core@...>

Issue #20335 has been reported by byroot (Jean Boussier).

13 messages 2024/03/14

[#117157] [Ruby master Misc#20336] DevMeeting-2024-04-17 — "mame (Yusuke Endoh) via ruby-core" <ruby-core@...>

Issue #20336 has been reported by mame (Yusuke Endoh).

15 messages 2024/03/14

[#117212] [Ruby master Feature#20345] Add `--target-rbconfig` option to mkmf — "katei (Yuta Saito) via ruby-core" <ruby-core@...>

Issue #20345 has been reported by katei (Yuta Saito).

9 messages 2024/03/18

[#117240] [Ruby master Feature#20350] Return chilled string from Symbol#to_s — "Dan0042 (Daniel DeLorme) via ruby-core" <ruby-core@...>

Issue #20350 has been reported by Dan0042 (Daniel DeLorme).

10 messages 2024/03/19

[#117288] [Ruby master Misc#20387] Meta-ticket for ASAN support — "kjtsanaktsidis (KJ Tsanaktsidis) via ruby-core" <ruby-core@...>

Issue #20387 has been reported by kjtsanaktsidis (KJ Tsanaktsidis).

10 messages 2024/03/22

[#117321] [Ruby master Bug#20393] `after_fork_ruby` clears all pending interrupts for both parent and child process. — "ioquatix (Samuel Williams) via ruby-core" <ruby-core@...>

Issue #20393 has been reported by ioquatix (Samuel Williams).

6 messages 2024/03/26

[#117324] [Ruby master Feature#20394] Add an offset parameter to `String#to_i` — "byroot (Jean Boussier) via ruby-core" <ruby-core@...>

Issue #20394 has been reported by byroot (Jean Boussier).

16 messages 2024/03/26

[#117341] [Ruby master Feature#20396] ObjectSpace.dump_all(string_value: false): skip dumping the String contents — "byroot (Jean Boussier) via ruby-core" <ruby-core@...>

Issue #20396 has been reported by byroot (Jean Boussier).

8 messages 2024/03/27

[#117390] [Ruby master Feature#20404] `2pi` — "mame (Yusuke Endoh) via ruby-core" <ruby-core@...>

Issue #20404 has been reported by mame (Yusuke Endoh).

9 messages 2024/03/31

[ruby-core:117195] [Ruby master Feature#20331] Should parser warn hash duplication and when clause?

From: "mame (Yusuke Endoh) via ruby-core" <ruby-core@...>
Date: 2024-03-15 05:53:07 UTC
List: ruby-core #117195
Issue #20331 has been updated by mame (Yusuke Endoh).


> But we don't want to remove the warnings, so the compiler will need to warn for those cases?

At the dev meeting, Matz said that the compiler doesn't need to warn those cases. He said that just remove the warning except literally conflict cases.

> To be clear, prism already runs on PicoRuby with this warning enabled, and it works just fine. Can you clarify what concerns you have here?

Matz said he wants to make the footprint as small as possible.

Subtle cases like `{ 1.0 => a, 1.00 => b }` and `{ "\x00" => a, "\0" => b }` were also discussed, and some committers wants to keep the warning for the cases, but Matz said no need to warn such cases.

In my personal opinion: the cases that I remember this warning useful are when I copy-pasted a key-value pair of Hash literal or `when` clause of `case` statement and forgot to edit them. I don't remember any real-world conflicts like `when 10; when 0xA`. So I also think that warning a literally conflict makes sense. Still a little nervous about something like `when 1.0; when 1.00`, though.

----------------------------------------
Feature #20331: Should parser warn hash duplication and when clause?
https://bugs.ruby-lang.org/issues/20331#change-107284

* Author: yui-knk (Kaneko Yuichiro)
* Status: Open
----------------------------------------
# Background

Right now, parser warns duplicated hash keys (#1) and when clause (#2).
For example,

```ruby
{1 => :a, 1 => :b}

# => warning: key 1 is duplicated and overwritten on line 1
```

```ruby
case 2
when 1, 1
else
end

# => test.rb:2: warning: duplicated `when' clause with line 2 is ignored
```

The parser compares different cardinality numbers.

```ruby
{
    1 => :a,
  0x1 => :b,
  0b1 => :b,
  0d1 => :b,
  0o1 => :b,
}

# => test.rb:2: warning: key 1 is duplicated and overwritten on line 3
# => test.rb:3: warning: key 1 is duplicated and overwritten on line 4
# => test.rb:4: warning: key 1 is duplicated and overwritten on line 5
# => test.rb:5: warning: key 1 is duplicated and overwritten on line 6
```

# Problem

Currently this is implemeted by converting string like `"123"` to Ruby Object and compare them.
It's needed to remove Ruby Object from parse.y for Universal Parser.
I created PR https://github.com/ruby/ruby/pull/10079 which implements bignum for parse.y without dependency on Ruby Object, however nobu and mame express concern about the cost and benefit of implmenting bignum for parser.
I want to discuss which is the best approach for this problem.

By the way, it's needed to calculate irreducible fraction for Rational key if we will keep warning messages.

```ruby
$ ruby -wc -e '{10.2r => :a, 10.2r => :b}'
-e:1: warning: key (51/5) is duplicated and overwritten on line 1
-e:1: warning: unused literal ignored
Syntax OK
```

# Options

## 1. Warnings on parser

Pros: 
* Users of Universal Parser don't need to implement warnings by themselves. I guess developers of other Ruby implementation may get benefit of reducing their effort.
* Warnings are shown by `ruby -wc`.

Cons:
* We need to maintain bignum implementation for parser.

There are two approaches for this option.

### 1-1. Implement bignum for parser

The PR is this approach, implementing sub set of Ruby bignum for parser.

### 1-2. Extract existing bignum implementation then use it

Make existing bignum implementation to be independent of Ruby Object and use it from both bignum.c and parse.y.

## 2. Moving warnings logic into compile phase

We can use Ruby Object in compile.c. Then moving the logic into compile.c solves this problem.

Pros:
* No need to implement bignum for parser.

Cons:
* Users of Universal Parser need to implement warnings by themselves.
* Warnings are not shown by `ruby -wc`.




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

In This Thread