# \`read(STDIN, UInt32)\` doesn't seem to respond to the type argument correctly

**URL:** <https://discourse.julialang.org/t/read-stdin-uint32-doesnt-seem-to-respond-to-the-type-argument-correctly/10308>\
**Category:** General Usage\
**Tags:** question\
**Created:** [April 12, 2018, 7:59pm UTC](https://discourse.julialang.org/t/read-stdin-uint32-doesnt-seem-to-respond-to-the-type-argument-correctly/10308 "2018-04-12T19:59:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![morrisonlevi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/morrisonlevi/32/3937_2.png) [@morrisonlevi](https://discourse.julialang.org/u/morrisonlevi)\
**Post date:** [April 12, 2018, 7:59pm UTC](https://discourse.julialang.org/t/read-stdin-uint32-doesnt-seem-to-respond-to-the-type-argument-correctly/10308/1 "2018-04-12T19:59:13Z")

</div>

Today I spent an hour or so helping someone track down a type inference issue. The crux of it is that `read(STDIN, UInt32)` is inferring a return type of ANY. This seems odd as we are directly passing a type as a parameter. I had the thought that perhaps it returns some other type if it fails, but I couldn’t find any such information in the docs. Is this a bug, intentional design, or me simply not understanding enough of the picture?

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [April 12, 2018, 8:01pm UTC](https://discourse.julialang.org/t/read-stdin-uint32-doesnt-seem-to-respond-to-the-type-argument-correctly/10308/2 "2018-04-12T20:01:26Z")

</div>

Probably worth opening an issue with a minimal reproducing example. The compiler should be able to figure out that `read(io, UInt32)` should have type `UInt32` but it may be getting confused somehow.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [April 12, 2018, 9:59pm UTC](https://discourse.julialang.org/t/read-stdin-uint32-doesnt-seem-to-respond-to-the-type-argument-correctly/10308/3 "2018-04-12T21:59:06Z")

</div>

~~Seems to work on 0.6, probably because the `read` call gets inlined there.~~ Nvm.

I think the problem is that `stdin` is not a constant so the compiler cannot know what `read` method will be called.

---

<div class="post-metadata">

**Author:** ![morrisonlevi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/morrisonlevi/32/3937_2.png) [@morrisonlevi](https://discourse.julialang.org/u/morrisonlevi)\
**Post date:** [April 18, 2018, 5:42pm UTC](https://discourse.julialang.org/t/read-stdin-uint32-doesnt-seem-to-respond-to-the-type-argument-correctly/10308/4 "2018-04-18T17:42:36Z")

</div>

Thanks for your responses. The simpler test cases are not reproducing it as expected so I’ll have to get the original code and try paring it down.
