* [ruby-core:119623] [Ruby master Bug#20817] Ruby 3.4.0dev emits `warning: possibly useless use of + in void context` while Ruby 3.3.5 does not
2024-10-26 3:45 [ruby-core:119622] [Ruby master Bug#20817] Ruby 3.4.0dev emits `warning: possibly useless use of + in void context` while Ruby 3.3.5 does not yahonda (Yasuo Honda) via ruby-core
@ 2024-10-26 3:47 ` yahonda (Yasuo Honda) via ruby-core
2024-10-26 3:47 ` [ruby-core:119624] " yahonda (Yasuo Honda) via ruby-core
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: yahonda (Yasuo Honda) via ruby-core @ 2024-10-26 3:47 UTC (permalink / raw)
To: ruby-core; +Cc: yahonda (Yasuo Honda)
Issue #20817 has been updated by yahonda (Yasuo Honda).
Here is the original Rails CI log file.
https://buildkite.com/rails/rails-nightly/builds/1214#0192c57b-b994-43cb-9f48-63b1b41e6f4e/1177-1185
"(eval at lib/file.rb:42):2: warning: possibly useless use of + in void context"
### How to reproduce this behavior locally
```ruby
git clone https://github.com/rails/rails
cd rails/actionpack
bundle install
bin/test test/dispatch/exception_wrapper_test.rb -n /source_extracts_works_with_eval_syntax_error/
```
```
$ ruby -v
ruby 3.4.0dev (2024-10-25T11:52:32Z master 9c8c140d73) +PRISM [x86_64-linux]
$ bin/test test/dispatch/exception_wrapper_test.rb -n /source_extracts_works_with_eval_syntax_error/
/home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/minitest-5.25.1/lib/minitest/mock.rb:33: warning: redefining 'object_id' may cause serious problems
/home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/capybara-3.40.0/lib/capybara/session/config.rb:95: warning: URI::RFC3986_PARSER.make_regexp is obsoleted. Use URI::RFC2396_PARSER.make_regexp explicitly.
Running 20 tests in a single process (parallelization threshold is 50)
Run options: -n /source_extracts_works_with_eval_syntax_error/ --seed 47290
# Running:
(eval at lib/file.rb:42):2: warning: possibly useless use of + in void context
.
Finished in 0.013903s, 71.9264 runs/s, 143.8528 assertions/s.
1 runs, 2 assertions, 0 failures, 0 errors, 0 skips
$
```
----------------------------------------
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-110243
* Author: yahonda (Yasuo Honda)
* Status: Open
* 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/
^ permalink raw reply [flat|nested] 8+ messages in thread
* [ruby-core:119624] [Ruby master Bug#20817] Ruby 3.4.0dev emits `warning: possibly useless use of + in void context` while Ruby 3.3.5 does not
2024-10-26 3:45 [ruby-core:119622] [Ruby master Bug#20817] Ruby 3.4.0dev emits `warning: possibly useless use of + in void context` while Ruby 3.3.5 does not 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 ` yahonda (Yasuo Honda) via ruby-core
2024-10-26 6:54 ` [ruby-core:119625] " Earlopain (A S) via ruby-core
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: yahonda (Yasuo Honda) via ruby-core @ 2024-10-26 3:47 UTC (permalink / raw)
To: ruby-core; +Cc: yahonda (Yasuo Honda)
Issue #20817 has been updated by yahonda (Yasuo Honda).
Using parse.y parser works as Ruby 3.3.5 does. No warnings emitted.
```
$ RUBYOPT=--parser=parse.y ruby -v
ruby 3.4.0dev (2024-10-25T11:52:32Z master 9c8c140d73) [x86_64-linux]
$ RUBYOPT=--parser=parse.y ruby -w foo.rb
lib/file.rb:42:in 'Kernel#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 'C#throw_syntax_error'
from foo.rb:7:in '<main>'
$
```
----------------------------------------
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-110244
* Author: yahonda (Yasuo Honda)
* Status: Open
* 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/
^ permalink raw reply [flat|nested] 8+ messages in thread
* [ruby-core:119625] [Ruby master Bug#20817] Ruby 3.4.0dev emits `warning: possibly useless use of + in void context` while Ruby 3.3.5 does not
2024-10-26 3:45 [ruby-core:119622] [Ruby master Bug#20817] Ruby 3.4.0dev emits `warning: possibly useless use of + in void context` while Ruby 3.3.5 does not 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 ` Earlopain (A S) via ruby-core
2024-10-26 9:40 ` [ruby-core:119627] " nobu (Nobuyoshi Nakada) via ruby-core
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Earlopain (A S) via ruby-core @ 2024-10-26 6:54 UTC (permalink / raw)
To: ruby-core; +Cc: Earlopain (A S)
Issue #20817 has been updated by Earlopain (A S).
Related to https://bugs.ruby-lang.org/issues/20736
----------------------------------------
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-110245
* Author: yahonda (Yasuo Honda)
* Status: Open
* 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/
^ permalink raw reply [flat|nested] 8+ messages in thread
* [ruby-core:119627] [Ruby master Bug#20817] Ruby 3.4.0dev emits `warning: possibly useless use of + in void context` while Ruby 3.3.5 does not
2024-10-26 3:45 [ruby-core:119622] [Ruby master Bug#20817] Ruby 3.4.0dev emits `warning: possibly useless use of + in void context` while Ruby 3.3.5 does not yahonda (Yasuo Honda) via ruby-core
` (2 preceding siblings ...)
2024-10-26 6:54 ` [ruby-core:119625] " Earlopain (A S) via ruby-core
@ 2024-10-26 9:40 ` nobu (Nobuyoshi Nakada) via ruby-core
2024-10-28 14:16 ` [ruby-core:119634] " kddnewton (Kevin Newton) via ruby-core
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2024-10-26 9:40 UTC (permalink / raw)
To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)
Issue #20817 has been updated by nobu (Nobuyoshi Nakada).
This seems the case that the recovery works wrongly.
When no syntax error, also the "useless use" warning occurs inside `eval`.
Not in `eval`, the warning is emitted regardless the syntax error.
----------------------------------------
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-110249
* Author: yahonda (Yasuo Honda)
* Status: Open
* 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/
^ permalink raw reply [flat|nested] 8+ messages in thread
* [ruby-core:119634] [Ruby master Bug#20817] Ruby 3.4.0dev emits `warning: possibly useless use of + in void context` while Ruby 3.3.5 does not
2024-10-26 3:45 [ruby-core:119622] [Ruby master Bug#20817] Ruby 3.4.0dev emits `warning: possibly useless use of + in void context` while Ruby 3.3.5 does not yahonda (Yasuo Honda) via ruby-core
` (3 preceding siblings ...)
2024-10-26 9:40 ` [ruby-core:119627] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2024-10-28 14:16 ` kddnewton (Kevin Newton) via ruby-core
2024-11-05 22:57 ` [ruby-core:119756] " kddnewton (Kevin Newton) via ruby-core
2024-12-12 11:06 ` [ruby-core:120211] " mame (Yusuke Endoh) via ruby-core
6 siblings, 0 replies; 8+ messages in thread
From: kddnewton (Kevin Newton) via ruby-core @ 2024-10-28 14:16 UTC (permalink / raw)
To: ruby-core; +Cc: kddnewton (Kevin Newton)
Issue #20817 has been updated by kddnewton (Kevin Newton).
Assignee set to kddnewton (Kevin Newton)
----------------------------------------
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-110254
* Author: yahonda (Yasuo Honda)
* Status: Open
* Assignee: kddnewton (Kevin Newton)
* 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/
^ permalink raw reply [flat|nested] 8+ messages in thread
* [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
2024-10-26 3:45 [ruby-core:119622] [Ruby master Bug#20817] Ruby 3.4.0dev emits `warning: possibly useless use of + in void context` while Ruby 3.3.5 does not yahonda (Yasuo Honda) via ruby-core
` (4 preceding siblings ...)
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
2024-12-12 11:06 ` [ruby-core:120211] " mame (Yusuke Endoh) via ruby-core
6 siblings, 0 replies; 8+ messages in thread
From: kddnewton (Kevin Newton) via ruby-core @ 2024-11-05 22:57 UTC (permalink / raw)
To: ruby-core; +Cc: kddnewton (Kevin Newton)
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/
^ permalink raw reply [flat|nested] 8+ messages in thread
* [ruby-core:120211] [Ruby master Bug#20817] Ruby 3.4.0dev emits `warning: possibly useless use of + in void context` while Ruby 3.3.5 does not
2024-10-26 3:45 [ruby-core:119622] [Ruby master Bug#20817] Ruby 3.4.0dev emits `warning: possibly useless use of + in void context` while Ruby 3.3.5 does not yahonda (Yasuo Honda) via ruby-core
` (5 preceding siblings ...)
2024-11-05 22:57 ` [ruby-core:119756] " kddnewton (Kevin Newton) via ruby-core
@ 2024-12-12 11:06 ` mame (Yusuke Endoh) via ruby-core
6 siblings, 0 replies; 8+ messages in thread
From: mame (Yusuke Endoh) via ruby-core @ 2024-12-12 11:06 UTC (permalink / raw)
To: ruby-core; +Cc: mame (Yusuke Endoh)
Issue #20817 has been updated by mame (Yusuke Endoh).
Status changed from Assigned to Rejected
Discussed at the dev meeting. This incompatibility that a subtle warning is printed when code is a syntax error should be considered minor and acceptable.
If the frequency or volume of the warning is high, or if it is difficult to suppress the warning, or if there are other circumstances that warrant consideration, then this may be reconsidered.
----------------------------------------
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-110974
* Author: yahonda (Yasuo Honda)
* Status: Rejected
* 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/
^ permalink raw reply [flat|nested] 8+ messages in thread