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

Tests not passing with 1.1 #30

Closed
tlienart opened this issue Dec 13, 2018 · 2 comments
Closed

Tests not passing with 1.1 #30

tlienart opened this issue Dec 13, 2018 · 2 comments

Comments

@tlienart
Copy link

tlienart commented Dec 13, 2018

Related to the Mega-Issue JuliaLang/julia#30374.

test_for

@resumable function test_for(a::Int=0; b::Int=a+1) :: Int
  for i in 1:10
    @yield a
    a, b = b, a+b
  end
end
collect(test_for(4))

this fails on 1.1. However this works:

@resumable function test_for(a::Int=0; b::Int=a+1, n::Int=10) :: Int
  for i in 1:n
    @yield a
    a, b = b, a+b
  end
end
collect(test_for(4)) # works

An issue seems to be with the transform_for with the line $next = iterate... where it looks like the right-hand-side gives a nothing and the left-hand side expects a Tuple{Int, Int} (I don't know enough about macros to know what causes this assignment to fail). The following "fixes" it:

function transform_for(expr, ui8::BoxedUInt8)
  @capture(expr, for element_ in iterator_ body__ end) || return expr
  ui8.n += one(UInt8)
  next = Symbol("_iteratornext_", ui8.n)
  state = Symbol("_iterstate_", ui8.n)
  iterator_value = Symbol("_iterator_", ui8.n)
  quote
    $iterator_value = $iterator
    $next = iterate($iterator_value)
    while $next != nothing
      ($element, $state) = $next
      $(body...)
      tmp = iterate($iterator_value, $state) # <---
      tmp === nothing && break               # <---
      $next = tmp                            # <---
    end
  end
end

test_try

@resumable function test_try(io)
  try
    a = 1
    @yield a
    a = 2
    c = @yield a
    println(io,c)
  catch except
    println(io,except)
    d = @yield
    println(io,d)
  finally
    println(io,"Always")
  end
end

fails with error syntax: Attempt to jump into catch block. Not sure what's going on there.

@BenLauwens
Copy link
Collaborator

Thanks!

test_for should work now in master
test_try is modified, Julia v1.1 does no longer support @goto into a catch statement... so I removed this feature...

Can you check?

@tlienart
Copy link
Author

Great, yes tests pass, there's just a couple of warnings

┌ Warning: @resumable function contains return statement with value!
└ @ ResumableFunctions ~/.julia/dev/ResumableFunctions/src/utils.jl:121
┌ Warning: @resumable function contains return statement with value!
└ @ ResumableFunctions ~/.julia/dev/ResumableFunctions/src/utils.jl:121

but that's it. Closing the issue!

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

2 participants