Skip to content

produce not being hit with type unstable variable #185

Closed
@mhauru

Description

@mhauru

MWE:

julia> function g()
                  if randn() > 0
                      x = 2
                  else
                      x = 0.1
                  end
                  produce(x)
              end
g (generic function with 1 method)

julia> show(Libtask.consume(Libtask.TapedTask(nothing, g)))
nothing

The fact that the type of x depends on runtime values seems to be significant. The following variants work as expected:

julia> function g()
                  if randn() > 0
                      x = 0.2
                  else
                      x = 0.1
                  end
                  produce(x)
              end
g (generic function with 1 method)

julia> show(Libtask.consume(Libtask.TapedTask(nothing, g)))
0.2

and

julia> function g()
                  if randn() isa Float64
                      x = 1
                  else
                      x = 0.1
                  end
                  produce(x)
              end
g (generic function with 1 method)

julia> show(Libtask.consume(Libtask.TapedTask(nothing, g)))
1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions