ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "kddnewton (Kevin Newton) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "kddnewton (Kevin Newton)" <noreply@ruby-lang.org>
Subject: [ruby-core:119756] [Ruby master Bug#20817] Ruby 3.4.0dev emits `warning: possibly useless use of + in void context` while Ruby 3.3.5 does not
Date: Tue, 05 Nov 2024 22:57:02 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-110421.20241105225702.2179@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-20817.20241026034540.2179@ruby-lang.org>

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

Assignee changed from kddnewton (Kevin Newton) to prism

----------------------------------------
Bug #20817: Ruby 3.4.0dev emits `warning: possibly useless use of + in void context` while Ruby 3.3.5 does not
https://bugs.ruby-lang.org/issues/20817#change-110421

* Author: yahonda (Yasuo Honda)
* Status: Open
* Assignee: prism
* ruby -v: ruby 3.4.0dev (2024-10-25T11:52:32Z master 9c8c140d73) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
Ruby 3.4.0dev emits `warning: possibly useless use of + in void context` while Ruby 3.3.5 does not

This issue is based on Rails Action Pack test case against Ruby 3.4.0dev.
Here is the minimum script to reproduce it.

### Steps to reproduce

- Create a sample foo.rb file
```
class C
  class_eval "def throw_syntax_error; eval %(
    'abc' + pluralize 'def'
  ); end", "lib/file.rb", 42
end
c = C.new
c.throw_syntax_error
```
- Run this foo.rb using Ruby 3.4.0dev

### Expected behavior
It should report SyntaxError, but it shoud not emit any warnings as Ruby 3.3.5 does not.

```
$ ruby -v
ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [x86_64-linux]
$ ruby -w foo.rb
lib/file.rb:42:in `eval': (eval at lib/file.rb:42):2: syntax error, unexpected string literal, expecting `do' or '{' or '(' (SyntaxError)
    'abc' + pluralize 'def'
                      ^

	from lib/file.rb:42:in `throw_syntax_error'
	from foo.rb:7:in `<main>'
```


### Actual behavior
It reports It should SyntaxError and it emits the `warning: possibly useless use of + in void context`

```
$ ruby -v
ruby 3.4.0dev (2024-10-25T11:52:32Z master 9c8c140d73) +PRISM [x86_64-linux]
$ ruby -w foo.rb
(eval at lib/file.rb:42):2: warning: possibly useless use of + in void context
lib/file.rb:42:in 'Kernel#eval': (eval at lib/file.rb:42):2: syntax error found (SyntaxError)
  1 |
> 2 |     'abc' + pluralize 'def'
    |                       ^ unexpected string literal, expecting end-of-input
  3 |

	from lib/file.rb:42:in 'C#throw_syntax_error'
	from foo.rb:7:in '<main>'
$
```



-- 
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/

      parent reply	other threads:[~2024-11-05 22:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-26  3:45 [ruby-core:119622] " yahonda (Yasuo Honda) via ruby-core
2024-10-26  3:47 ` [ruby-core:119623] " yahonda (Yasuo Honda) via ruby-core
2024-10-26  3:47 ` [ruby-core:119624] " yahonda (Yasuo Honda) via ruby-core
2024-10-26  6:54 ` [ruby-core:119625] " Earlopain (A S) via ruby-core
2024-10-26  9:40 ` [ruby-core:119627] " nobu (Nobuyoshi Nakada) via ruby-core
2024-10-28 14:16 ` [ruby-core:119634] " kddnewton (Kevin Newton) via ruby-core
2024-11-05 22:57 ` kddnewton (Kevin Newton) via ruby-core [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-110421.20241105225702.2179@ruby-lang.org \
    --to=ruby-core@ml.ruby-lang.org \
    --cc=noreply@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).