fonsp / Pluto.jl

🎈 Simple reactive notebooks for Julia
https://plutojl.org/
MIT License
4.91k stars 284 forks source link

Incorrect dependency for nested functions #2864

Closed Alseidon closed 3 months ago

Alseidon commented 3 months ago

image

results from this notebook:

### A Pluto.jl notebook ###
# v0.19.9

using Markdown
using InteractiveUtils

# ╔═╡ 33533c42-ed09-11ee-0da9-818a477aafad
function func_1(a)
    res = func_2(a)
end

# ╔═╡ 9ccf6b10-fbac-4145-b8e7-99faa7138e2e
a = func_1(3)

# ╔═╡ 8e1c7bb0-1efe-4ee9-b476-32e842ebb050
function func_2(a)
    return a + 2
end

# ╔═╡ 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.10.2"
manifest_format = "2.0"
project_hash = "da39a3ee5e6b4b0d3255bfef95601890afd80709"

[deps]
"""

# ╔═╡ Cell order:
# ╠═9ccf6b10-fbac-4145-b8e7-99faa7138e2e
# ╠═33533c42-ed09-11ee-0da9-818a477aafad
# ╠═8e1c7bb0-1efe-4ee9-b476-32e842ebb050
# ╟─00000000-0000-0000-0000-000000000001
# ╟─00000000-0000-0000-0000-000000000002

This happens if you write the func_1 definition before (chronologically) func_2.

I can't remember if this was a thing in previous Pluto versions.

Alseidon commented 3 months ago

Actually, it seems to me any function not in Base cannot be used in other functions:

### A Pluto.jl notebook ###
# v0.19.9

using Markdown
using InteractiveUtils

# ╔═╡ 737bd099-7a9e-401c-aeec-f3192c9a8d35
using LinearAlgebra

# ╔═╡ e6df4106-a416-4f92-82c1-01082fa3c6da
f(x) = x+2

# ╔═╡ a60396b8-4fbf-4b3c-ac98-c1755b880850
f(1)

# ╔═╡ 638550d1-5c8c-414a-9ee2-94711ae2c2b3
(i->f(i))(5)

# ╔═╡ 256fa571-9a1c-4501-898c-b3370bf23a5c
(i->sqrt(i))(2)

# ╔═╡ 98661117-f6e6-439a-8343-4b0f8540ccec
(i->norm(i))(2)

# ╔═╡ 00000000-0000-0000-0000-000000000001
PLUTO_PROJECT_TOML_CONTENTS = """
[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
"""

# ╔═╡ 00000000-0000-0000-0000-000000000002
PLUTO_MANIFEST_TOML_CONTENTS = """
# This file is machine-generated - editing it directly is not advised

julia_version = "1.10.2"
manifest_format = "2.0"
project_hash = "ac1187e548c6ab173ac57d4e72da1620216bce54"

[[deps.Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"

[[deps.CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
version = "1.1.0+0"

[[deps.Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[[deps.LinearAlgebra]]
deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[[deps.OpenBLAS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
version = "0.3.23+4"

[[deps.libblastrampoline_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
version = "5.8.0+1"
"""

# ╔═╡ Cell order:
# ╠═737bd099-7a9e-401c-aeec-f3192c9a8d35
# ╠═e6df4106-a416-4f92-82c1-01082fa3c6da
# ╠═a60396b8-4fbf-4b3c-ac98-c1755b880850
# ╠═256fa571-9a1c-4501-898c-b3370bf23a5c
# ╠═638550d1-5c8c-414a-9ee2-94711ae2c2b3
# ╠═98661117-f6e6-439a-8343-4b0f8540ccec
# ╟─00000000-0000-0000-0000-000000000001
# ╟─00000000-0000-0000-0000-000000000002

gives

image

Using include on the notebook file in the Julia REPL works just fine.

fonsp commented 3 months ago

Can you update Pluto and try again? Your version is almost 2 years old.

Alseidon commented 3 months ago

Can you update Pluto and try again? Your version is almost 2 years old.

I'm so sorry I didn't realize... Running the same notebooks with v0.19.40 works just fine.

Installing Plotly.jl in the same environment actually restricted Pluto to this version, because of a conflict on HTTP.jl version. My bad: