Closed
Description
I wrote the equivalent of this earlier and it baffled me for several minutes.
fn size_of<T>() -> uint {
// Expecting (though unreasonably) the type parameter to be
// inferred to T, it is actually inferred to something byte-sized (nil?)
sys::size_of()
}
fn main() {
// Why does size_of::<u32>() return 1?
assert size_of::<u32>() == 4u;
}
It works correctly when you write sys::size_of::<T>()
. I don't think this should typecheck.