Pluto.jl
Pluto.jl copied to clipboard
methods on custom structs defined inside macros are not deleted on re-run
I noticed that when using macros to generate block of code that contains custom struct and custom methods defined on those, older methods are not deleted upon re-run. This is not the case when the same codeblock is directly put in a cell rather than inside a macro.
This also creates another instance of the duplicated docstrings (if they are also present in the macro body) like in closed issues #1708 and #1932.
Tagging @Pangoraw directly as he is the macro wizard
Here is a video example:
https://user-images.githubusercontent.com/12846528/169555817-e1cdd435-92e2-4dac-9515-240077be3f74.mp4
and here is the notebook code:
Notebook source
### A Pluto.jl notebook ###
# v0.19.5
using Markdown
using InteractiveUtils
# ╔═╡ c4311933-7b49-4d3c-bca7-2adbf8a1a029
begin
struct ASD end
asdasd(::ASD) = "asd"
end
# ╔═╡ ad3fd6a4-d883-4329-8522-1b1f2304a4b3
methods(asdasd)
# ╔═╡ 142c7ad0-16d4-4af3-924c-a8f633c504a4
macro lol()
quote
struct LOL end
lolol(::LOL) = "lol"
end |> esc
end
# ╔═╡ 3b345bcb-46fa-4db1-89aa-cbd928c5fb82
@lol
# ╔═╡ 665302b7-5806-4c48-a307-dcebff544dd2
methods(lolol)
# ╔═╡ 00000000-0000-0000-0000-000000000001
PLUTO_PROJECT_TOML_CONTENTS = """
[deps]
"""
# ╔═╡ 00000000-0000-0000-0000-000000000002
PLUTO_MANIFEST_TOML_CONTENTS = """
# This file is machine-generated - editing it directly is not advised
julia_version = "1.7.1"
manifest_format = "2.0"
[deps]
"""
# ╔═╡ Cell order:
# ╠═c4311933-7b49-4d3c-bca7-2adbf8a1a029
# ╠═ad3fd6a4-d883-4329-8522-1b1f2304a4b3
# ╠═142c7ad0-16d4-4af3-924c-a8f633c504a4
# ╠═3b345bcb-46fa-4db1-89aa-cbd928c5fb82
# ╠═665302b7-5806-4c48-a307-dcebff544dd2
# ╟─00000000-0000-0000-0000-000000000001
# ╟─00000000-0000-0000-0000-000000000002
I guess that's also why memoized functions from Memoize.jl are not deleted either.