-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Invalid memory access in Array#push #8594
Comments
Only # ary=[] of UInt64
# p! ary.push(3) # => Program received and didn't handle signal ILL (4)
# ary=[] of UInt32
# p! ary.push(3) # => Program received and didn't handle signal ILL (4)
# ary=[] of UInt16
# p! ary.push(3) # => Program received and didn't handle signal ILL (4)
# ary=[] of UInt8
# p! ary.push(3) # => Program received and didn't handle signal ILL (4)
# ary=[] of Int64
# p! ary.push(3) # => Program received and didn't handle signal ILL (4)
ary=[] of Int32
p! ary.push(3) # => [3]
# ary=[] of Int16
# p! ary.push(3) # => Program received and didn't handle signal ILL (4)
# ary=[] of Int8
# p! ary.push(3) # => Program received and didn't handle signal ILL (4) Crystal 0.32.0 on MacOS
|
It seems to be a bug with autocasting. It works fine if you do |
BTW, is that by design that Should't there be this variant too? class Array(T)
def <<(*values : T)
push(*values)
end
end Then |
@vlazar the syntax doesn't allow calling |
@asterite Thanks. Yeah, that was my though. I just wanted to be sure it was not forgotten, but deliberately not added in the first place. |
I'm certain this is #8217. If it is, close for dupe? |
Duplicate of #8217 |
Array#push fails
Output
Array#<< works
Note however that locally I have this error instead for Array#push:
Crystal 0.32.0 on MacOS
The behavior changed many times in previous versions of Crystal. Although I'm not sure if I can trust playground.
In Crystal 0.24.2 both Array#push and Array#<< gives
no overload matches
error.Since Crystal 0.25.0 Array#push is broken and Array#<< works.
Since Crystal 0.27.0 Array#push gives
ambiguous call, implicit cast of 3 matches all of UInt32
and Array#<< works.SInce Crystal 0.29.0 Array#push gives
Program received and didn't handle signal SYS (31)
and Array#<< works.SInce Crystal 0.31.0 Array#push gives
Invalid memory access
and Array#<< works.The text was updated successfully, but these errors were encountered: