implicit return lines reported active by coverage but not tracked in julia 1.10.2Β #53557
Description
Hello all,
I found that "implicit return" lines that contain only a variables are counted into lines that "should be covered" by tests but the coverage testing doesn't work on them.
For reproducers, I have a small package that only has this single source file:
module covtest
greet() = print("Hello World!")
function testfun(n)
[ begin
x = i
x = x * x
x = x + x
x = x / x
x
end for i=1:n]
end
function testfun2(n)
a = n
a *= n
a += n
a /= n
a
end
end # module covtest
and this runtests.jl
file:
import covtest: testfun, testfun2
testfun(10)
testfun2(10)
The coverage produced by running ]test --coverage covtest
is as follows:
- module covtest
-
- greet() = print("Hello World!")
-
1 function testfun(n)
1 [ begin
10 x = i
10 x = x * x
10 x = x + x
10 x = x / x
0 x
- end for i=1:n]
- end
-
1 function testfun2(n)
1 a = n
1 a *= n
1 a += n
1 a /= n
0 a
- end
-
- end # module covtest
This gets worked around by either adding explicit returns, or having a function called in the loops on the end (the explicit return can't be used there) -- e.g. as follows:
- module covtest
-
- greet() = print("Hello World!")
-
1 function testfun(n)
1 [ begin
10 x = i
10 x = x * x
10 x = x + x
10 x = x / x
10 identity(x)
- end for i=1:n]
- end
-
1 function testfun2(n)
1 a = n
1 a *= n
1 a += n
1 a /= n
1 return a
- end
-
- end # module covtest
For the functions I assume the return
there is adviseable, but for the implicit values of begin
/end
blocks this actually seems like a regression to me. I originally thought this is somehow triggered by switch to JuliaSyntax (I could not reproduce this on <1.10), but the same problem happens with JULIA_USE_FLISP_PARSER=1
so maybe not. I'd expect that this could be caused by some part of codegen optimistically assuming that "this won't generate any code!!" and just dropping the whole line, but I wasn't able to find any commit/change/sourcecode to blame there, so it might also be something entirely different.
In case this is now the desired behavior, is there docs somewhere? (I just checked the release notes for 1.10 to be triple sure :D )
Thanks for any help/opinions on this :)
Best!
-mk
Activity