Bug #9519

Wrong multiline calculation

Added by Victor Daev 2 months ago. Updated 2 months ago.

[ruby-core:60733]
Status:Rejected
Priority:Normal
Assignee:-
Category:-
Target version:-
ruby -v:ruby 2.1.0p0 (2013-12-25 revision 44422) [i686-linux], ruby 2.0.0p353 (2013-11-22 revision 43784) [i686-linux], ruby 1.9.3p484 (2013-11-22 revision 43786) [i686-linux] Backport:1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN

Description

I have some script with a trouble.

p(100 - (1 + 2 + 3 + 4))

=> 90

ok

p(100 - (1 +
2 +
3 +
4))

=> 90

ok

p(100 - (1
+ 2
+ 3
+ 4))

=> 96

BUT it should be 90

If I run the script I will get

$ rvm use 1.9.3
Using /home/user/.rvm/gems/ruby-1.9.3-p484
$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [i686-linux]
$ ruby wrongmultilinecalculation.rb
90
90
96

$ rvm use 2.0.0
Using /home/user/.rvm/gems/ruby-2.0.0-p353
$ ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [i686-linux]
$ ruby wrongmultilinecalculation.rb
90
90
96

$ rvm use 2.1
Using /home/user/.rvm/gems/ruby-2.1.0
$ ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [i686-linux]
$ ruby wrongmultilinecalculation.rb
90
90
96

wrong_multiline_calculation.rb Magnifier (138 Bytes) Victor Daev, 02/14/2014 10:04 AM

History

#1 Updated by Victor Daev 2 months ago

Ooops. How can I fix the layout?

#2 Updated by Victor Daev 2 months ago

p(100 - (1 + 2 + 3 + 4))
# => 90
# ok

p(100 - (1 +
2 +
3 +
4))
# => 90
# ok

p(100 - (1
+ 2
+ 3
+ 4))
# => 96
# BUT it should be 90

#3 Updated by Heesob Park 2 months ago

I think this issue is not a bug.

p(100 - (1
+ 2
+ 3
+ 4))

is interpreted as

p(100-(1;+2;+3;+4))

#4 Updated by Victor Daev 2 months ago

Heesob Park wrote:

I think this issue is not a bug.
p(100 - (1
+ 2
+ 3
+ 4))
is interpreted as
p(100-(1;+2;+3;+4))

Is it ok? How about "the Principle of Least Surprise"?

#5 Updated by Nobuyoshi Nakada 2 months ago

  • Status changed from Open to Rejected

PoLS is not for Ruby.

Also available in: Atom PDF