-
Notifications
You must be signed in to change notification settings - Fork 1
Description
First off, this package is really cool and I enjoy using it a lot :)
I think I found a bug in the 0.9 version of this package that I can reproduce with the setup below. The last cell of the example notebook errors when I run it with PlutoDevMacros version 0.9.1 but didn't error on 0.8.1. Or is what I'm doing not supposed to work in the first place?
What I'm trying to do is use an object whose type is defined directly in the top-level module of MyPackage, but which was constructed in a submodule MyPackage.SubModule. In 0.9.1, this object seems to be different to Pluto somehow so that methods with argument type restrictions don't accept it anymore. Also the test t2 == t returned true on 0.8.1, but false 0.9.1 (so the whole MethodError below is probably just the symptom of this).
Reproduce:
- create a dummy package
julia -e 'using Pkg; Pkg.generate("MyPackage") - add content to
MyPackage/src/MyPackage.jlwith some structMyThingand a submoduleSubmodule
module MyPackage
struct MyThing
a::Int
end
get_a(t::MyThing) = t.a
function do_stuff(t::MyThing)
a = get_a(t)
return a * rand()
end
module SubModule
using MyPackage: MyThing
function construct_thing(a)
return MyThing(a)
end
end
end- create test environments
MyPackage/notebooks/PDM_0.8.1and run insidejulia --project=. -e 'using Pkg; Pkg.add(name="PlutoDevMacros", version="0.8.1")'(and analogous for version 0.9.1). - create a notebook
MyPackage/notebooks/notebooks.jlwith
### A Pluto.jl notebook ###
# v0.20.20
using Markdown
using InteractiveUtils
# ╔═╡ f6cd2c49-2318-46a1-a945-57b688a96735
begin
using Pkg
Pkg.activate("PDM_0.8.1")
end
# ╔═╡ ddaf67f2-e383-41c1-aa79-8f76d8871d1e
using PlutoDevMacros
# ╔═╡ e964e090-0ba5-4e1c-9126-499fc6718257
@frompackage ".." begin
using MyPackage
end
# ╔═╡ 8542d7d4-1ef1-473f-aed5-984b5d43372b
t = MyPackage.MyThing(1)
# ╔═╡ 6469268a-65f9-494c-97c8-f2603df95296
t2 = MyPackage.SubModule.construct_thing(1)
# ╔═╡ 75f20939-9dd4-4cc6-bc3a-65488399d440
t2 == t
# ╔═╡ d698b4e7-08c8-4fbf-968f-56c1aed8991c
MyPackage.do_stuff(t)
# ╔═╡ ac91061c-e01c-489f-92e5-e6f016ff9c4f
MyPackage.do_stuff(t2)
# ╔═╡ Cell order:
# ╠═f6cd2c49-2318-46a1-a945-57b688a96735
# ╠═ddaf67f2-e383-41c1-aa79-8f76d8871d1e
# ╠═e964e090-0ba5-4e1c-9126-499fc6718257
# ╠═8542d7d4-1ef1-473f-aed5-984b5d43372b
# ╠═6469268a-65f9-494c-97c8-f2603df95296
# ╠═75f20939-9dd4-4cc6-bc3a-65488399d440
# ╠═d698b4e7-08c8-4fbf-968f-56c1aed8991c
# ╠═ac91061c-e01c-489f-92e5-e6f016ff9c4f- run the notebook and change between
Pkg.activate("PDM_0.8.1")andPkg.activate("PDM_0.9.1")
For 0.8.1 I get no errors, for 0.9.1 I get
MethodError: no method matching do_stuff(::MyPackage.MyThing)
The function `do_stuff` exists, but no method is defined for this combination of argument types.
Closest candidates are:
do_stuff(::Main.var"workspace#3".var"##TempModule#283".MyPackage.MyThing)
@ Main.var"workspace#3" .../MyPackage/src/MyPackage.jl:11
I've tested this on Julia 1.12 (where 0.8.1 gives a warning and should probably not be used) but also on Julia 1.10 with the same result.
It might be a bit of a niche error, but it would be very useful if this would work again. For now, I can manually downgrade PlutoDevMacros to 0.8.1, but it's inconvenient to not use the internal Package manager of Pluto just for one package in a large notebook.
I would also be happy to think about a fix if you could point me in the right direction (at the moment, I have no idea how this package works internally though 😅 )