Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Truffle] String operations produce the wrong result #4016

Closed
chrisseaton opened this issue Jul 14, 2016 · 4 comments
Closed

[Truffle] String operations produce the wrong result #4016

chrisseaton opened this issue Jul 14, 2016 · 4 comments
Assignees
Milestone

Comments

@chrisseaton
Copy link
Contributor

n = 4
src = "GGC"
l = src.length
s = src * ((n / l) + 1)

puts "n=#{n}"
puts "src=#{src}"
puts "l=#{l}"
puts "s=#{s}"

s.slice!(n, l)
puts "result: #{s}"

MRI

n=4
src=GGC
l=3
s=GGCGGC
result: GGCG

JRuby+Truffle

n=4
src=GGC
l=3
s=GGCGGC
result: GGC

Also

$ hexdump -C ruby_output 
00000000  6e 3d 34 0a 73 72 63 3d  47 47 43 0a 6c 3d 33 0a  |n=4.src=GGC.l=3.|
00000010  73 3d 47 47 43 47 47 43  0a 72 65 73 75 6c 74 3a  |s=GGCGGC.result:|
00000020  20 47 47 43 47 0a                                 | GGCG.|
00000026
$ hexdump -C jruby_output 
00000000  6e 3d 34 0a 73 72 63 3d  47 47 43 0a 6c 3d 33 0a  |n=4.src=GGC.l=3.|
00000010  73 3d 47 47 43 47 47 43  0a 72 65 73 75 6c 74 3a  |s=GGCGGC.result:|
00000020  20 47 47 43 00 0a                                 | GGC..|
00000026

From @vext01

@chrisseaton chrisseaton added this to the truffle-dev milestone Jul 14, 2016
@chrisseaton chrisseaton self-assigned this Jul 14, 2016
@chrisseaton
Copy link
Contributor Author

Simpler:

s = 'GGC' * 2
s.slice!(4, 3)
p s

MRI: "GGCG"

JRuby+Truffle: "GGC\u0000"

@chrisseaton
Copy link
Contributor Author

Simpler:

s = 'GGC' * 2
s[4, 3] = ''
p s

Same result as before.

@chrisseaton
Copy link
Contributor Author

Simpler:

s = 'GGC' * 2
#s = 'GGCGGC'
m = Rubinius::Mirror.reflect s
m.splice 4, 2, '', s.encoding
p s

@chrisseaton
Copy link
Contributor Author

@nirvdrum can I hand this off to you? Something wrong in concat of substrings of repeated ropes.

@chrisseaton chrisseaton assigned nirvdrum and unassigned chrisseaton Jul 14, 2016
@enebo enebo added this to the Non-Release milestone Dec 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants