ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:120618] [Ruby master Bug#21029] Prism behavior for `defined? (;x)` differs
@ 2025-01-12  2:58 qnighy (Masaki Hara) via ruby-core
  2025-01-12 18:58 ` [ruby-core:120624] " kddnewton (Kevin Newton) via ruby-core
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: qnighy (Masaki Hara) via ruby-core @ 2025-01-12  2:58 UTC (permalink / raw)
  To: ruby-core; +Cc: qnighy (Masaki Hara)

Issue #21029 has been reported by qnighy (Masaki Hara).

----------------------------------------
Bug #21029: Prism behavior for `defined? (;x)` differs
https://bugs.ruby-lang.org/issues/21029

* Author: qnighy (Masaki Hara)
* Status: Open
* ruby -v: ruby 3.5.0dev (2025-01-11T03:21:57Z master 1b3037081e) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Prism has a different behavior for `(;expr)` when used in `defined?` predicate:

```console
% ./miniruby --parser=prism -e "p defined? (;x)"
nil
% ./miniruby --parser=parse.y -e "p defined? (;x)"
"expression"
```

Although not a significant difference, aligning either of them with the other would be better.



-- 
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] 12+ messages in thread

* [ruby-core:120624] [Ruby master Bug#21029] Prism behavior for `defined? (;x)` differs
  2025-01-12  2:58 [ruby-core:120618] [Ruby master Bug#21029] Prism behavior for `defined? (;x)` differs qnighy (Masaki Hara) via ruby-core
@ 2025-01-12 18:58 ` kddnewton (Kevin Newton) via ruby-core
  2025-01-14 23:52 ` [ruby-core:120673] " kddnewton (Kevin Newton) via ruby-core
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: kddnewton (Kevin Newton) via ruby-core @ 2025-01-12 18:58 UTC (permalink / raw)
  To: ruby-core; +Cc: kddnewton (Kevin Newton)

Issue #21029 has been updated by kddnewton (Kevin Newton).

Assignee set to prism

----------------------------------------
Bug #21029: Prism behavior for `defined? (;x)` differs
https://bugs.ruby-lang.org/issues/21029#change-111454

* Author: qnighy (Masaki Hara)
* Status: Open
* Assignee: prism
* ruby -v: ruby 3.5.0dev (2025-01-11T03:21:57Z master 1b3037081e) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Prism has a different behavior for `(;expr)` when used in `defined?` predicate:

```console
% ./miniruby --parser=prism -e "p defined? (;x)"
nil
% ./miniruby --parser=parse.y -e "p defined? (;x)"
"expression"
```

Although not a significant difference, aligning either of them with the other would be better.



-- 
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] 12+ messages in thread

* [ruby-core:120673] [Ruby master Bug#21029] Prism behavior for `defined? (;x)` differs
  2025-01-12  2:58 [ruby-core:120618] [Ruby master Bug#21029] Prism behavior for `defined? (;x)` differs qnighy (Masaki Hara) via ruby-core
  2025-01-12 18:58 ` [ruby-core:120624] " kddnewton (Kevin Newton) via ruby-core
@ 2025-01-14 23:52 ` kddnewton (Kevin Newton) via ruby-core
  2025-02-13  6:41 ` [ruby-core:120966] " matz (Yukihiro Matsumoto) via ruby-core
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: kddnewton (Kevin Newton) via ruby-core @ 2025-01-14 23:52 UTC (permalink / raw)
  To: ruby-core; +Cc: kddnewton (Kevin Newton)

Issue #21029 has been updated by kddnewton (Kevin Newton).


I think we should change `parse.y` to match this behavior. I will ask around.

----------------------------------------
Bug #21029: Prism behavior for `defined? (;x)` differs
https://bugs.ruby-lang.org/issues/21029#change-111497

* Author: qnighy (Masaki Hara)
* Status: Open
* Assignee: prism
* ruby -v: ruby 3.5.0dev (2025-01-11T03:21:57Z master 1b3037081e) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Prism has a different behavior for `(;expr)` when used in `defined?` predicate:

```console
% ./miniruby --parser=prism -e "p defined? (;x)"
nil
% ./miniruby --parser=parse.y -e "p defined? (;x)"
"expression"
```

Although not a significant difference, aligning either of them with the other would be better.



-- 
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] 12+ messages in thread

* [ruby-core:120966] [Ruby master Bug#21029] Prism behavior for `defined? (;x)` differs
  2025-01-12  2:58 [ruby-core:120618] [Ruby master Bug#21029] Prism behavior for `defined? (;x)` differs qnighy (Masaki Hara) via ruby-core
  2025-01-12 18:58 ` [ruby-core:120624] " kddnewton (Kevin Newton) via ruby-core
  2025-01-14 23:52 ` [ruby-core:120673] " kddnewton (Kevin Newton) via ruby-core
@ 2025-02-13  6:41 ` matz (Yukihiro Matsumoto) via ruby-core
  2025-02-13  7:03 ` [ruby-core:120968] " qnighy (Masaki Hara) via ruby-core
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: matz (Yukihiro Matsumoto) via ruby-core @ 2025-02-13  6:41 UTC (permalink / raw)
  To: ruby-core; +Cc: matz (Yukihiro Matsumoto)

Issue #21029 has been updated by matz (Yukihiro Matsumoto).


I think compound expressions (expressions (including empty) concatenated by semicolons) should be “expression” as `parse.y`.
It makes `defined?` simpler. I know the current `defined?` behavior recursively check for defined-ness (e.g., method parameters), I don't think we need that complexity here.

Matz.

----------------------------------------
Bug #21029: Prism behavior for `defined? (;x)` differs
https://bugs.ruby-lang.org/issues/21029#change-111865

* Author: qnighy (Masaki Hara)
* Status: Assigned
* Assignee: prism
* ruby -v: ruby 3.5.0dev (2025-01-11T03:21:57Z master 1b3037081e) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Prism has a different behavior for `(;expr)` when used in `defined?` predicate:

```console
% ./miniruby --parser=prism -e "p defined? (;x)"
nil
% ./miniruby --parser=parse.y -e "p defined? (;x)"
"expression"
```

Although not a significant difference, aligning either of them with the other would be better.



-- 
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] 12+ messages in thread

* [ruby-core:120968] [Ruby master Bug#21029] Prism behavior for `defined? (;x)` differs
  2025-01-12  2:58 [ruby-core:120618] [Ruby master Bug#21029] Prism behavior for `defined? (;x)` differs qnighy (Masaki Hara) via ruby-core
                   ` (2 preceding siblings ...)
  2025-02-13  6:41 ` [ruby-core:120966] " matz (Yukihiro Matsumoto) via ruby-core
@ 2025-02-13  7:03 ` qnighy (Masaki Hara) via ruby-core
  2025-02-13 18:07 ` [ruby-core:120988] " kddnewton (Kevin Newton) via ruby-core
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: qnighy (Masaki Hara) via ruby-core @ 2025-02-13  7:03 UTC (permalink / raw)
  To: ruby-core; +Cc: qnighy (Masaki Hara)

Issue #21029 has been updated by qnighy (Masaki Hara).


> I think compound expressions (expressions (including empty) concatenated by semicolons) should be “expression” as `parse.y`.

Interestingly enough though:

```
% ruby --parser=prism -e "p defined? (x;)"
nil
% ruby --parser=parse.y -e "p defined? (x;)"
nil

% ruby --parser=prism -e "p defined? (;x)"
nil
% ruby --parser=parse.y -e "p defined? (;x)"
"expression"
```

----------------------------------------
Bug #21029: Prism behavior for `defined? (;x)` differs
https://bugs.ruby-lang.org/issues/21029#change-111867

* Author: qnighy (Masaki Hara)
* Status: Assigned
* Assignee: prism
* ruby -v: ruby 3.5.0dev (2025-01-11T03:21:57Z master 1b3037081e) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Prism has a different behavior for `(;expr)` when used in `defined?` predicate:

```console
% ./miniruby --parser=prism -e "p defined? (;x)"
nil
% ./miniruby --parser=parse.y -e "p defined? (;x)"
"expression"
```

Although not a significant difference, aligning either of them with the other would be better.



-- 
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] 12+ messages in thread

* [ruby-core:120988] [Ruby master Bug#21029] Prism behavior for `defined? (;x)` differs
  2025-01-12  2:58 [ruby-core:120618] [Ruby master Bug#21029] Prism behavior for `defined? (;x)` differs qnighy (Masaki Hara) via ruby-core
                   ` (3 preceding siblings ...)
  2025-02-13  7:03 ` [ruby-core:120968] " qnighy (Masaki Hara) via ruby-core
@ 2025-02-13 18:07 ` kddnewton (Kevin Newton) via ruby-core
  2025-03-13 11:25 ` [ruby-core:121329] " mame (Yusuke Endoh) via ruby-core
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: kddnewton (Kevin Newton) via ruby-core @ 2025-02-13 18:07 UTC (permalink / raw)
  To: ruby-core; +Cc: kddnewton (Kevin Newton)

Issue #21029 has been updated by kddnewton (Kevin Newton).


@matz for what it's worth, it makes it much more complicated in the Prism compiler because we don't have empty statements. So it's not a recursive situation at the moment, it's just a single statement.

As @qnighy points out, should this be "expression" for when there is a trailing `;`?

----------------------------------------
Bug #21029: Prism behavior for `defined? (;x)` differs
https://bugs.ruby-lang.org/issues/21029#change-111892

* Author: qnighy (Masaki Hara)
* Status: Assigned
* Assignee: prism
* ruby -v: ruby 3.5.0dev (2025-01-11T03:21:57Z master 1b3037081e) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Prism has a different behavior for `(;expr)` when used in `defined?` predicate:

```console
% ./miniruby --parser=prism -e "p defined? (;x)"
nil
% ./miniruby --parser=parse.y -e "p defined? (;x)"
"expression"
```

Although not a significant difference, aligning either of them with the other would be better.



-- 
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] 12+ messages in thread

* [ruby-core:121329] [Ruby master Bug#21029] Prism behavior for `defined? (;x)` differs
  2025-01-12  2:58 [ruby-core:120618] [Ruby master Bug#21029] Prism behavior for `defined? (;x)` differs qnighy (Masaki Hara) via ruby-core
                   ` (4 preceding siblings ...)
  2025-02-13 18:07 ` [ruby-core:120988] " kddnewton (Kevin Newton) via ruby-core
@ 2025-03-13 11:25 ` mame (Yusuke Endoh) via ruby-core
  2025-03-18 18:55 ` [ruby-core:121401] [Ruby " kddnewton (Kevin Newton) via ruby-core
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mame (Yusuke Endoh) via ruby-core @ 2025-03-13 11:25 UTC (permalink / raw)
  To: ruby-core; +Cc: mame (Yusuke Endoh)

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


Discussed at the dev meeting.

kddnewton (Kevin Newton) wrote in #note-6:
> As @qnighy points out, should this be "expression" for when there is a trailing `;`?

@matz said "yes"; `defined? (x;)` should also return `"expression"`.

----------------------------------------
Bug #21029: Prism behavior for `defined? (;x)` differs
https://bugs.ruby-lang.org/issues/21029#change-112296

* Author: qnighy (Masaki Hara)
* Status: Assigned
* Assignee: prism
* ruby -v: ruby 3.5.0dev (2025-01-11T03:21:57Z master 1b3037081e) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Prism has a different behavior for `(;expr)` when used in `defined?` predicate:

```console
% ./miniruby --parser=prism -e "p defined? (;x)"
nil
% ./miniruby --parser=parse.y -e "p defined? (;x)"
"expression"
```

Although not a significant difference, aligning either of them with the other would be better.



-- 
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] 12+ messages in thread

* [ruby-core:121401] [Ruby Bug#21029] Prism behavior for `defined? (;x)` differs
  2025-01-12  2:58 [ruby-core:120618] [Ruby master Bug#21029] Prism behavior for `defined? (;x)` differs qnighy (Masaki Hara) via ruby-core
                   ` (5 preceding siblings ...)
  2025-03-13 11:25 ` [ruby-core:121329] " mame (Yusuke Endoh) via ruby-core
@ 2025-03-18 18:55 ` kddnewton (Kevin Newton) via ruby-core
  2025-03-18 18:55 ` [ruby-core:121402] " kddnewton (Kevin Newton) via ruby-core
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: kddnewton (Kevin Newton) via ruby-core @ 2025-03-18 18:55 UTC (permalink / raw)
  To: ruby-core; +Cc: kddnewton (Kevin Newton)

Issue #21029 has been updated by kddnewton (Kevin Newton).


I have updated Prism with https://github.com/ruby/ruby/commit/adaaa7878ebee62888bf3547d14c1db4938da88a, but the added test fails for `parse.y`. I haven't had a chance to look at it yet, but maybe someone else with more familiarity could.

----------------------------------------
Bug #21029: Prism behavior for `defined? (;x)` differs
https://bugs.ruby-lang.org/issues/21029#change-112376

* Author: qnighy (Masaki Hara)
* Status: Assigned
* Assignee: prism
* ruby -v: ruby 3.5.0dev (2025-01-11T03:21:57Z master 1b3037081e) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Prism has a different behavior for `(;expr)` when used in `defined?` predicate:

```console
% ./miniruby --parser=prism -e "p defined? (;x)"
nil
% ./miniruby --parser=parse.y -e "p defined? (;x)"
"expression"
```

Although not a significant difference, aligning either of them with the other would be better.



-- 
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] 12+ messages in thread

* [ruby-core:121402] [Ruby Bug#21029] Prism behavior for `defined? (;x)` differs
  2025-01-12  2:58 [ruby-core:120618] [Ruby master Bug#21029] Prism behavior for `defined? (;x)` differs qnighy (Masaki Hara) via ruby-core
                   ` (6 preceding siblings ...)
  2025-03-18 18:55 ` [ruby-core:121401] [Ruby " kddnewton (Kevin Newton) via ruby-core
@ 2025-03-18 18:55 ` kddnewton (Kevin Newton) via ruby-core
  2025-07-08 14:23 ` [ruby-core:122679] " S_H_ (Shun Hiraoka) via ruby-core
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: kddnewton (Kevin Newton) via ruby-core @ 2025-03-18 18:55 UTC (permalink / raw)
  To: ruby-core; +Cc: kddnewton (Kevin Newton)

Issue #21029 has been updated by kddnewton (Kevin Newton).

Assignee deleted (prism)

----------------------------------------
Bug #21029: Prism behavior for `defined? (;x)` differs
https://bugs.ruby-lang.org/issues/21029#change-112377

* Author: qnighy (Masaki Hara)
* Status: Assigned
* ruby -v: ruby 3.5.0dev (2025-01-11T03:21:57Z master 1b3037081e) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Prism has a different behavior for `(;expr)` when used in `defined?` predicate:

```console
% ./miniruby --parser=prism -e "p defined? (;x)"
nil
% ./miniruby --parser=parse.y -e "p defined? (;x)"
"expression"
```

Although not a significant difference, aligning either of them with the other would be better.



-- 
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] 12+ messages in thread

* [ruby-core:122679] [Ruby Bug#21029] Prism behavior for `defined? (;x)` differs
  2025-01-12  2:58 [ruby-core:120618] [Ruby master Bug#21029] Prism behavior for `defined? (;x)` differs qnighy (Masaki Hara) via ruby-core
                   ` (7 preceding siblings ...)
  2025-03-18 18:55 ` [ruby-core:121402] " kddnewton (Kevin Newton) via ruby-core
@ 2025-07-08 14:23 ` S_H_ (Shun Hiraoka) via ruby-core
  2025-07-08 14:34 ` [ruby-core:122680] " kddnewton (Kevin Newton) via ruby-core
  2025-07-14 12:25 ` [ruby-core:122741] " S_H_ (Shun Hiraoka) via ruby-core
  10 siblings, 0 replies; 12+ messages in thread
From: S_H_ (Shun Hiraoka) via ruby-core @ 2025-07-08 14:23 UTC (permalink / raw)
  To: ruby-core; +Cc: S_H_ (Shun Hiraoka)

Issue #21029 has been updated by S_H_ (Shun Hiraoka).


I've fixed that defined? (x;) returns an expression when using parse.y.

https://github.com/ruby/ruby/pull/13821

However, I have a little skeptical about whether this change is a good idea. If any other good suggestions, I would appreciate it if you could comment.

----------------------------------------
Bug #21029: Prism behavior for `defined? (;x)` differs
https://bugs.ruby-lang.org/issues/21029#change-113959

* Author: qnighy (Masaki Hara)
* Status: Closed
* ruby -v: ruby 3.5.0dev (2025-01-11T03:21:57Z master 1b3037081e) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Prism has a different behavior for `(;expr)` when used in `defined?` predicate:

```console
% ./miniruby --parser=prism -e "p defined? (;x)"
nil
% ./miniruby --parser=parse.y -e "p defined? (;x)"
"expression"
```

Although not a significant difference, aligning either of them with the other would be better.



-- 
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] 12+ messages in thread

* [ruby-core:122680] [Ruby Bug#21029] Prism behavior for `defined? (;x)` differs
  2025-01-12  2:58 [ruby-core:120618] [Ruby master Bug#21029] Prism behavior for `defined? (;x)` differs qnighy (Masaki Hara) via ruby-core
                   ` (8 preceding siblings ...)
  2025-07-08 14:23 ` [ruby-core:122679] " S_H_ (Shun Hiraoka) via ruby-core
@ 2025-07-08 14:34 ` kddnewton (Kevin Newton) via ruby-core
  2025-07-14 12:25 ` [ruby-core:122741] " S_H_ (Shun Hiraoka) via ruby-core
  10 siblings, 0 replies; 12+ messages in thread
From: kddnewton (Kevin Newton) via ruby-core @ 2025-07-08 14:34 UTC (permalink / raw)
  To: ruby-core; +Cc: kddnewton (Kevin Newton)

Issue #21029 has been updated by kddnewton (Kevin Newton).


@S_H_ I agree, I think the overhead is not worth it in this case and we should pretend the `;` do not exist on both cases.

----------------------------------------
Bug #21029: Prism behavior for `defined? (;x)` differs
https://bugs.ruby-lang.org/issues/21029#change-113960

* Author: qnighy (Masaki Hara)
* Status: Closed
* ruby -v: ruby 3.5.0dev (2025-01-11T03:21:57Z master 1b3037081e) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Prism has a different behavior for `(;expr)` when used in `defined?` predicate:

```console
% ./miniruby --parser=prism -e "p defined? (;x)"
nil
% ./miniruby --parser=parse.y -e "p defined? (;x)"
"expression"
```

Although not a significant difference, aligning either of them with the other would be better.



-- 
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] 12+ messages in thread

* [ruby-core:122741] [Ruby Bug#21029] Prism behavior for `defined? (;x)` differs
  2025-01-12  2:58 [ruby-core:120618] [Ruby master Bug#21029] Prism behavior for `defined? (;x)` differs qnighy (Masaki Hara) via ruby-core
                   ` (9 preceding siblings ...)
  2025-07-08 14:34 ` [ruby-core:122680] " kddnewton (Kevin Newton) via ruby-core
@ 2025-07-14 12:25 ` S_H_ (Shun Hiraoka) via ruby-core
  10 siblings, 0 replies; 12+ messages in thread
From: S_H_ (Shun Hiraoka) via ruby-core @ 2025-07-14 12:25 UTC (permalink / raw)
  To: ruby-core; +Cc: S_H_ (Shun Hiraoka)

Issue #21029 has been updated by S_H_ (Shun Hiraoka).



I agree that consistent behavior between both cases would be ideal.  
Given the current structure of `parse.y`, wrapping with `NODE_BLOCK` seems like the most straightforward approach to make both `defined?(;x)` and `defined?(x;)` return `"expression"`.

With my current changes, both forms now generate the same AST nodes, which I believe improves consistency across the board.

Also, I want to clarify my earlier comment about being "skeptical" — I was specifically referring to adding new parameters to the `parser_params` struct, not to the `NODE_BLOCK` wrapping approach itself. Sorry for any confusion caused.

Right now, the `defined?(x;)` test is failing on `parse.y`, which makes it hard to assess whether changes to `universal_parser.c` or other components are affecting the `parse.y` behavior. This adds friction when trying to work on parser-related modifications.

From a maintenance standpoint, I believe fixing this failing test would help ensure that future `parse.y` changes can be validated more reliably.  
Would you be open to keeping this change in order to maintain test consistency?


----------------------------------------
Bug #21029: Prism behavior for `defined? (;x)` differs
https://bugs.ruby-lang.org/issues/21029#change-114022

* Author: qnighy (Masaki Hara)
* Status: Closed
* ruby -v: ruby 3.5.0dev (2025-01-11T03:21:57Z master 1b3037081e) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Prism has a different behavior for `(;expr)` when used in `defined?` predicate:

```console
% ./miniruby --parser=prism -e "p defined? (;x)"
nil
% ./miniruby --parser=parse.y -e "p defined? (;x)"
"expression"
```

Although not a significant difference, aligning either of them with the other would be better.



-- 
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] 12+ messages in thread

end of thread, other threads:[~2025-07-14 12:26 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-12  2:58 [ruby-core:120618] [Ruby master Bug#21029] Prism behavior for `defined? (;x)` differs qnighy (Masaki Hara) via ruby-core
2025-01-12 18:58 ` [ruby-core:120624] " kddnewton (Kevin Newton) via ruby-core
2025-01-14 23:52 ` [ruby-core:120673] " kddnewton (Kevin Newton) via ruby-core
2025-02-13  6:41 ` [ruby-core:120966] " matz (Yukihiro Matsumoto) via ruby-core
2025-02-13  7:03 ` [ruby-core:120968] " qnighy (Masaki Hara) via ruby-core
2025-02-13 18:07 ` [ruby-core:120988] " kddnewton (Kevin Newton) via ruby-core
2025-03-13 11:25 ` [ruby-core:121329] " mame (Yusuke Endoh) via ruby-core
2025-03-18 18:55 ` [ruby-core:121401] [Ruby " kddnewton (Kevin Newton) via ruby-core
2025-03-18 18:55 ` [ruby-core:121402] " kddnewton (Kevin Newton) via ruby-core
2025-07-08 14:23 ` [ruby-core:122679] " S_H_ (Shun Hiraoka) via ruby-core
2025-07-08 14:34 ` [ruby-core:122680] " kddnewton (Kevin Newton) via ruby-core
2025-07-14 12:25 ` [ruby-core:122741] " S_H_ (Shun Hiraoka) 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).