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

inferred type for eachline() is lost in v0.6 #20351

Closed
ghost opened this issue Jan 31, 2017 · 3 comments
Closed

inferred type for eachline() is lost in v0.6 #20351

ghost opened this issue Jan 31, 2017 · 3 comments
Labels
io Involving the I/O subsystem: libuv, read, write, etc. regression Regression in behavior compared to a previous version

Comments

@ghost
Copy link

ghost commented Jan 31, 2017

julia> Base.Test.@inferred eachline(STDIN)
ERROR: return type EachLine does not match inferred return type Any
Stacktrace:
 [1] error(::String) at ./error.jl:21

julia> versioninfo()
Julia Version 0.6.0-dev.2481
Commit 2d86c42* (2017-01-30 22:50 UTC)

works fine in v0.5

julia> Base.Test.@inferred eachline(STDIN)
EachLine(Base.TTY(open, 0 bytes waiting),Base.#281)

julia> versioninfo()
Julia Version 0.5.0
Commit 3c9d753* (2016-09-19 18:14 UTC)

and then when used in a loop the eltype() is not known either:

julia> f() = for k in eachline(STDIN); @show k; end
f (generic function with 2 methods)

julia> @code_warntype f()
Variables:
  #self#::#f
  k::Any
  value::Any
  #temp#::Any

Body:
  begin 
      SSAValue(0) = (Main.eachline)(Main.STDIN)::Any
      #temp#::Any = (Base.start)(SSAValue(0))::Any
      3: 
      unless !((Base.done)(SSAValue(0),#temp#::Any)::Any)::Any goto 26
      SSAValue(1) = (Base.next)(SSAValue(0),#temp#::Any)::Any
      k::Any = (Core.getfield)(SSAValue(1),1)::Any
      #temp#::Any = (Core.getfield)(SSAValue(1),2)::Any # line 1:
      SSAValue(2) = "k = "
      # meta: location show.jl # line 251:
@pabloferz pabloferz added io Involving the I/O subsystem: libuv, read, write, etc. regression Regression in behavior compared to a previous version labels Jan 31, 2017
@pabloferz
Copy link
Contributor

Should get fixed by #20345

@JeffBezanson
Copy link
Member

Sadly it won't; that PR doesn't affect inference.

@pabloferz
Copy link
Contributor

pabloferz commented Jan 31, 2017

Well, this is easy enough to fix (work around), so #20356...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
io Involving the I/O subsystem: libuv, read, write, etc. regression Regression in behavior compared to a previous version
Projects
None yet
Development

No branches or pull requests

2 participants