ParseErrors in Julia 1.10 for manually `eval`'d expressions give misleading code location
disberd opened this issue Β· comments
Alberto Mengali commented
This is a mirror/duplicate of disberd/PlutoDevMacros.jl#30
Since #2526, on Julia 1.10 Pluto has fancy rendering of ParseErrors.
While this works fine for most of the reasonable use cases, when manually parsing expressions from files and evaluating them with Core.eval
(or similar), the error displayed on the cell output has a wrong hyperlink to a non-existing line in the current cell, and it can break codemirror for the cell in question.
Video Example:
b7f1726b-4203-4135-905f-f213a6398709.mp4
Notebook Code
### A Pluto.jl notebook ###
# v0.19.38
using Markdown
using InteractiveUtils
# βββ‘ 7b263142-cf29-11ee-3688-1352da3b20bf
fname = tempname()
# βββ‘ b0e94947-7098-4979-947b-01ebcc6aee9c
open(fname, "w") do io
write(io, """
module ASD
a = 1
b = 2
c = 3
""")
end
# βββ‘ eda9e79f-a7be-49c9-b451-72af19b30311
macro parse_error(fname)
fname = esc(fname)
:(let
filename = $fname
code = read(filename, String)
ast = Meta.parseall(code; filename)
Core.eval($__module__, ast)
end)
end
# βββ‘ Cell order:
# β β7b263142-cf29-11ee-3688-1352da3b20bf
# β βb0e94947-7098-4979-947b-01ebcc6aee9c
# β βeda9e79f-a7be-49c9-b451-72af19b30311
Maybe it would be sufficient to do fancy display of ParseErrors only if the source file has the cell UUID at the end of the filename? @Pangoraw