Confusing error, or how to clear stale compiler state

I think I’m having a problem with some stale compilation state.

This is in julia version 1.6.0.

When I run my unit tests I get this error:

     Testing Running tests...
ERROR: LoadError: LoadError: syntax: invalid interpolation syntax
Stacktrace:
  [1] top-level scope
    @ ~\.julia\dev\Tangle\src\links.jl:147

The offending line of code (the call to print) is commented out:

#=
function Base.showerror(io::IO, e::AlreadyLinked)
    print(io, "Link already has a $(e.direction) link.")
end
=#

I don’t understand what was wrong with it before I commented it out, and I have no clue what’s wrong with it now that it is commented out.

How do I flush whatever broken state is misguiding the compiler or runtime?

Thanks.

How do you run the tests? If you use the pkg> test it should behave as if you’ve started a new session. If you include tests manually, this is not the case.

I do

Pkg.test("Tangle")

How do you run the tests? If you use the pkg> test it should behave as if you’ve started a new session. If you include tests manually, this is not the case.

I just emptied .julia//compiled, restarted julia and tried my tests again. Same error, so I guess it’s not stale compilation state unless there’s more state elsewhere.

Why is it finding a string interpolation syntax error in a line of code that is commented out?

#=
function Base.showerror(io::IO, e::AlreadyLinked)
    print(io, "Link already has a $(e.direction) link.")
end
=#

Long session transcriopt follows:

julia
  Activating environment at `c:\Users\Mark Nahabedian\.julia\dev\Tangle\Project.toml`
using Pkg
Pkg.test("Tangle")
     Testing Tangle
      Status `C:\Users\Mark Nahabedian\AppData\Local\Temp\jl_6vsU21\Project.toml`
  [864edb3b] DataStructures v0.18.10
  [c8e1da08] IterTools v1.3.0
  [90137ffa] StaticArrays v1.2.12
  [324d6a3d] Tangle v0.1.0 `C:\Users\Mark Nahabedian\.julia\dev\Tangle`
  [b77e0a4c] InteractiveUtils `@stdlib/InteractiveUtils`
  [37e2e46d] LinearAlgebra `@stdlib/LinearAlgebra`
  [8dfed614] Test `@stdlib/Test`
      Status `C:\Users\Mark Nahabedian\AppData\Local\Temp\jl_6vsU21\Manifest.toml`
  [34da2185] Compat v3.34.0
  [864edb3b] DataStructures v0.18.10
  [c8e1da08] IterTools v1.3.0
  [bac558e1] OrderedCollections v1.4.1
  [90137ffa] StaticArrays v1.2.12
  [324d6a3d] Tangle v0.1.0 `C:\Users\Mark Nahabedian\.julia\dev\Tangle`
  [0dad84c5] ArgTools `@stdlib/ArgTools`
  [56f22d72] Artifacts `@stdlib/Artifacts`
  [2a0f44e3] Base64 `@stdlib/Base64`
  [ade2ca70] Dates `@stdlib/Dates`
  [8bb1440f] DelimitedFiles `@stdlib/DelimitedFiles`
  [8ba89e20] Distributed `@stdlib/Distributed`
  [f43a241f] Downloads `@stdlib/Downloads`
  [b77e0a4c] InteractiveUtils `@stdlib/InteractiveUtils`
  [b27032c2] LibCURL `@stdlib/LibCURL`
  [76f85450] LibGit2 `@stdlib/LibGit2`
  [8f399da3] Libdl `@stdlib/Libdl`
  [37e2e46d] LinearAlgebra `@stdlib/LinearAlgebra`
  [56ddb016] Logging `@stdlib/Logging`
  [d6f4376e] Markdown `@stdlib/Markdown`
  [a63ad114] Mmap `@stdlib/Mmap`
  [ca575930] NetworkOptions `@stdlib/NetworkOptions`
  [44cfe95a] Pkg `@stdlib/Pkg`
  [de0858da] Printf `@stdlib/Printf`
  [3fa0cd96] REPL `@stdlib/REPL`
  [9a3f8284] Random `@stdlib/Random`
  [ea8e919c] SHA `@stdlib/SHA`
  [9e88b42a] Serialization `@stdlib/Serialization`
  [1a1011a3] SharedArrays `@stdlib/SharedArrays`
  [6462fe0b] Sockets `@stdlib/Sockets`
  [2f01184e] SparseArrays `@stdlib/SparseArrays`
  [10745b16] Statistics `@stdlib/Statistics`
  [fa267f1f] TOML `@stdlib/TOML`
  [a4e569a6] Tar `@stdlib/Tar`
  [8dfed614] Test `@stdlib/Test`
  [cf7118a7] UUIDs `@stdlib/UUIDs`
  [4ec0a83e] Unicode `@stdlib/Unicode`
  [deac9b47] LibCURL_jll `@stdlib/LibCURL_jll`
  [29816b5a] LibSSH2_jll `@stdlib/LibSSH2_jll`
  [c8ffd9c3] MbedTLS_jll `@stdlib/MbedTLS_jll`
  [14a3606d] MozillaCACerts_jll `@stdlib/MozillaCACerts_jll`
  [83775a58] Zlib_jll `@stdlib/Zlib_jll`
  [8e850ede] nghttp2_jll `@stdlib/nghttp2_jll`
  [3f19e933] p7zip_jll `@stdlib/p7zip_jll`
Precompiling project...
  ✓ IterTools
  ✓ Compat
  ✓ Zlib_jll
  ✓ MbedTLS_jll
  ✓ LibSSH2_jll
  ✓ DataStructures
  ✓ StaticArrays
  ✗ Tangle
7 dependencies successfully precompiled in 14 seconds (1 already precompiled)
1 dependency errored
     Testing Running tests...
ERROR: LoadError: LoadError: syntax: invalid interpolation syntax
Stacktrace:
  [1] top-level scope
    @ ~\.julia\dev\Tangle\src\links.jl:147
  [2] include(mod::Module, _path::String)
    @ Base .\Base.jl:386
  [3] include(x::String)
    @ Tangle ~\.julia\dev\Tangle\src\Tangle.jl:1
  [4] top-level scope
    @ ~\.julia\dev\Tangle\src\Tangle.jl:12
  [5] include
    @ .\Base.jl:386 [inlined]
  [6] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
    @ Base .\loading.jl:1213
  [7] top-level scope
    @ none:1
  [8] eval
    @ .\boot.jl:360 [inlined]
  [9] eval(x::Expr)
    @ Base.MainInclude .\client.jl:446
 [10] top-level scope
    @ none:1
in expression starting at C:\Users\Mark Nahabedian\.julia\dev\Tangle\src\links.jl:147
in expression starting at C:\Users\Mark Nahabedian\.julia\dev\Tangle\src\Tangle.jl:1
ERROR: LoadError: Failed to precompile Tangle [324d6a3d-8d47-4281-bb16-2f63593471e6] to C:\Users\Mark Nahabedian\.julia\compiled\v1.6\Tangle\jl_280C.tmp.
Stacktrace:
 [1] error(s::String)
   @ Base .\error.jl:33
 [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::Base.PipeEndpoint, internal_stdout::Base.PipeEndpoint)
   @ Base .\loading.jl:1360
 [3] compilecache(pkg::Base.PkgId, path::String)
   @ Base .\loading.jl:1306
 [4] _require(pkg::Base.PkgId)
   @ Base .\loading.jl:1021
 [5] require(uuidkey::Base.PkgId)
   @ Base .\loading.jl:914
 [6] require(into::Module, mod::Symbol)
   @ Base .\loading.jl:901
 [7] include(fname::String)
   @ Base.MainInclude .\client.jl:444
 [8] top-level scope
   @ none:6
in expression starting at C:\Users\Mark Nahabedian\.julia\dev\Tangle\test\runtests.jl:1
ERROR: Package Tangle errored during testing
Stacktrace:
  [1] pkgerror(msg::String)
    @ Pkg.Types C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Types.jl:55
  [2] test(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; coverage::Bool, julia_args::Cmd, test_args::Cmd, test_fn::Nothing)
    @ Pkg.Operations C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:1687
  [3] test(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; coverage::Bool, test_fn::Nothing, julia_args::Cmd, test_args::Cmd, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Pkg.API C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:336
  [4] test(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec})
    @ Pkg.API C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:323
  [5] #test#62
    @ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:73 [inlined]
  [6] test
    @ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:72 [inlined]
  [7] #test#61
    @ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:70 [inlined]
  [8] test
    @ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:70 [inlined]
  [9] test(pkg::String; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Pkg.API C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:69
 [10] test(pkg::String)
    @ Pkg.API C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:69
 [11] top-level scope
    @ none:1

I’ve run into this as well. I’m not sure the reason, but it can probably be fixed by a PR to the parser.

Do things work when you get rid of that comment?

Thanks. Actually removing the code found my real problem. My bug actually confused the Gnu Emacs indenter, which, surprise, isn’t able to implement the exact same syntax rules as the parser.

Removing the commented out code got me this error instead:

ERROR: LoadError: LoadError: syntax: use "x^y" instead of "x**y" for exponentiation, and "x..." instead of "**x" for splatting.

which is complaining about a sequence of three asterisks at what I thought and expected was the beginning of a string. If that’s actually the end of a string instead, then the beginning is at (using C-M-b in emacs)

        println("Move from $was to $(link.where.")

on line 128, which is missing a close paren for a string intercollation.

I would not have guessed that Julia was parsing strings for intercollation syntax at the same time it was parsing the strings themselves, but that appears to be what’s happening.

Thanks for your help. I was totally stumped by this.