ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:120350] [Ruby master Bug#20974] Required and optional anonymous parameter show differently in Proc#parameters
@ 2024-12-20 23:18 alanwu (Alan Wu) via ruby-core
  2024-12-20 23:40 ` [ruby-core:120351] " alanwu (Alan Wu) via ruby-core
  2025-01-09 11:36 ` [ruby-core:120570] " mame (Yusuke Endoh) via ruby-core
  0 siblings, 2 replies; 3+ messages in thread
From: alanwu (Alan Wu) via ruby-core @ 2024-12-20 23:18 UTC (permalink / raw)
  To: ruby-core; +Cc: alanwu (Alan Wu)

Issue #20974 has been reported by alanwu (Alan Wu).

----------------------------------------
Bug #20974: Required and optional anonymous parameter show differently in Proc#parameters
https://bugs.ruby-lang.org/issues/20974

* Author: alanwu (Alan Wu)
* Status: Open
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
The following has had the same output since Ruby 1.9, when Proc#parameters was [introduced]:


```ruby
p(proc   { |(_a)| }.parameters) # => [[:opt, nil]]
p(lambda { |(_a)| }.parameters) # => [[:req]]
```

I think they should be `[[:opt]]` and `[[:req]]` or `[[:opt, nil]]` and `[[:req, nil]]`. I prefer the nil-free option since that feels more anonymous. 

[added]: https://docs.ruby-lang.org/en/master/NEWS/NEWS-1_9_2.html



-- 
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/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:120351] [Ruby master Bug#20974] Required and optional anonymous parameter show differently in Proc#parameters
  2024-12-20 23:18 [ruby-core:120350] [Ruby master Bug#20974] Required and optional anonymous parameter show differently in Proc#parameters alanwu (Alan Wu) via ruby-core
@ 2024-12-20 23:40 ` alanwu (Alan Wu) via ruby-core
  2025-01-09 11:36 ` [ruby-core:120570] " mame (Yusuke Endoh) via ruby-core
  1 sibling, 0 replies; 3+ messages in thread
From: alanwu (Alan Wu) via ruby-core @ 2024-12-20 23:40 UTC (permalink / raw)
  To: ruby-core; +Cc: alanwu (Alan Wu)

Issue #20974 has been updated by alanwu (Alan Wu).


It's not hard to patch this small issue. We need consensus on whether this is an issue and what the new behavior should be, though.

```diff
diff --git a/iseq.c b/iseq.c
index 639ca3a4cd..d5808b81a5 100644
--- a/iseq.c
+++ b/iseq.c
@@ -3606,7 +3606,9 @@ rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc)
     if (is_proc) {
         for (i = 0; i < body->param.lead_num; i++) {
             PARAM_TYPE(opt);
-            rb_ary_push(a, rb_id2str(PARAM_ID(i)) ? ID2SYM(PARAM_ID(i)) : Qnil);
+            if (rb_id2str(PARAM_ID(i))) {
+                rb_ary_push(a, ID2SYM(PARAM_ID(i)));
+            }
             rb_ary_push(args, a);
         }
     }
```

----------------------------------------
Bug #20974: Required and optional anonymous parameter show differently in Proc#parameters
https://bugs.ruby-lang.org/issues/20974#change-111131

* Author: alanwu (Alan Wu)
* Status: Open
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
The following has had the same output since Ruby 1.9, when Proc#parameters was [introduced]:


```ruby
p(proc   { |(_a)| }.parameters) # => [[:opt, nil]]
p(lambda { |(_a)| }.parameters) # => [[:req]]
```

I think they should be `[[:opt]]` and `[[:req]]` or `[[:opt, nil]]` and `[[:req, nil]]`. I prefer the nil-free option since that feels more anonymous. 

[introduced]: https://docs.ruby-lang.org/en/master/NEWS/NEWS-1_9_2.html



-- 
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/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:120570] [Ruby master Bug#20974] Required and optional anonymous parameter show differently in Proc#parameters
  2024-12-20 23:18 [ruby-core:120350] [Ruby master Bug#20974] Required and optional anonymous parameter show differently in Proc#parameters alanwu (Alan Wu) via ruby-core
  2024-12-20 23:40 ` [ruby-core:120351] " alanwu (Alan Wu) via ruby-core
@ 2025-01-09 11:36 ` mame (Yusuke Endoh) via ruby-core
  1 sibling, 0 replies; 3+ messages in thread
From: mame (Yusuke Endoh) via ruby-core @ 2025-01-09 11:36 UTC (permalink / raw)
  To: ruby-core; +Cc: mame (Yusuke Endoh)

Issue #20974 has been updated by mame (Yusuke Endoh).


Discussed at the dev meeting. @matz said that it should return `[[:opt]]` instead of `[[:opt, nil]]`.

----------------------------------------
Bug #20974: Required and optional anonymous parameter show differently in Proc#parameters
https://bugs.ruby-lang.org/issues/20974#change-111394

* Author: alanwu (Alan Wu)
* Status: Open
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
The following has had the same output since Ruby 1.9, when Proc#parameters was [introduced]:


```ruby
p(proc   { |(_a)| }.parameters) # => [[:opt, nil]]
p(lambda { |(_a)| }.parameters) # => [[:req]]
```

I think they should be `[[:opt]]` and `[[:req]]` or `[[:opt, nil]]` and `[[:req, nil]]`. I prefer the nil-free option since that feels more anonymous. 

[introduced]: https://docs.ruby-lang.org/en/master/NEWS/NEWS-1_9_2.html



-- 
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/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-09 11:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-20 23:18 [ruby-core:120350] [Ruby master Bug#20974] Required and optional anonymous parameter show differently in Proc#parameters alanwu (Alan Wu) via ruby-core
2024-12-20 23:40 ` [ruby-core:120351] " alanwu (Alan Wu) via ruby-core
2025-01-09 11:36 ` [ruby-core:120570] " mame (Yusuke Endoh) via ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).