From a7cb9a6b9bddd26895a98fe7fd4349b8e0d1d403 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Wed, 22 Sep 2021 11:34:45 +0200 Subject: [PATCH] [bugfix] only pass line number to logger if code block was found, fixes #1698 (#1699) --- src/DocTests.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DocTests.jl b/src/DocTests.jl index 3f293a259d..e3a33364e5 100644 --- a/src/DocTests.jl +++ b/src/DocTests.jl @@ -382,6 +382,7 @@ import .Utilities.TextDiff function report(result::Result, str, doc::Documents.Document) diff = TextDiff.Diff{TextDiff.Words}(result.output, rstrip(str)) lines = Utilities.find_block_in_file(result.block.code, result.file) + line = lines === nothing ? nothing : first(lines) @error(""" doctest failure in $(Utilities.locrepr(result.file, lines)) @@ -401,7 +402,7 @@ function report(result::Result, str, doc::Documents.Document) $(result.output) - """, diff, _file=result.file, _line=lines[1]) + """, diff, _file=result.file, _line=line) end function fix_doctest(result::Result, str, doc::Documents.Document)