Bug in @testset with @test_throws?

Writing some tests yesterday I discovered the following weird behavior difference between a test inside and outside a @testset. This seems to be the case when returning a type (in this case Void) from the function being tested.

I realized I was making a mistake and should return nothing instead, but I think still the two tests should pass in this case, or I’m misunderstanding something. This is in Julia v0.6.1 and also in the latest v0.5:

function someFunction(vec::Vector{String})
    @assert length(vec) > 1 "Vector too small"

    # yes, I know this is a bit weird here
    return Void

using Base.Test

@testset "Some test set" begin
    # this will fail and say it didn't throw
    @test_throws AssertionError someFunction(String[])

# this test will pass
@test_throws AssertionError someFunction(String[])

Simpler repro:

using Base.Test

foo() = (assert(false); return Void)

@test_throws AssertionError foo()

@testset begin @test_throws AssertionError foo() end

It seems like it is connected to return Void because if I change that to e.g. return nothing the failure goes away. Note also that this is working as expected on the master branch.

Also, do you want to return Void (the type)? Usually one returns nothing (the instance) instead.

Exactly, if an instance is returned (nothing) then it’s alright. I am planning to return the instance but I still wanted to report the ‘bug’.
Is master v0.7? Then I guess it’s not very critical, except if anyone finds this important to be backported. Thanks.


If you (or anyone else) finds the commit that fixed this it could potentially be backported.