-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Scoping issue in @testset
#17170
Comments
Nice MCVE. |
AFAIK, this is the expected behavior in a local scope. So should |
Test sets introduce a new scope by design since, like |
In another word this is a |
I'm not sure how this is a dup of #14948 since there are no threads involved, but I do think we need to decide if this is the right behavior for test sets and it does perhaps shed some light on one of the more potentially confusing corners of Julia's scoping rules. @JeffBezanson may be interested. |
#14948 is not really about threading but the scope lifting due to a variable with the same name in the outer scope |
Chalk up another point for requiring |
That seems like it may well make the scoping rules simpler and clearer. |
I also encountered the problem. This case may be much harder to notice: using Base.Test
@testset begin
@testset "foo" begin
sum = 1
end
@testset "bar" begin
mktemp() do path, io
@test sum([1,2,3]) == 6
end
end
end |
Original example now warns and the second one works. |
The following piece of code:
gives the output:
Notice that
a
has changed and shouldn't.The text was updated successfully, but these errors were encountered: