Skip to content
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

ParseErrors in Julia 1.10 for manually eval'd expressions give misleading code location #2819

Closed
disberd opened this issue Feb 19, 2024 · 1 comment · Fixed by #2820
Closed

Comments

@disberd
Copy link
Contributor

disberd commented Feb 19, 2024

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

@Pangoraw
Copy link
Collaborator

I did not realize parse errors could come from Meta.parse, thank you. With #2820, diagnostics will only come from Pluto parsed expressions and not notebook thrown exceptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants