Closed
Description
The bug:
function f(s, price)
@show f
f = s * price
end
f(2, 3)
ERROR: LoadError: UndefVarError: `f` not defined
Stacktrace:
[1] macro expansion
@ Main ./show.jl:1153 [inlined]
[2] f(s::Int64, price::Int64)
@ Main ~/git/julia/bug.jl:2
[3] top-level scope
@ ~/git/julia/bug.jl:5
in expression starting at /home/apaz/git/julia/bug.jl:5
User's versioninfo()
:
julia> versioninfo()
Julia Version 1.9.0
Commit 8e630552924 (2023-05-07 11:25 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 24 × AMD Ryzen 9 7900X 12-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-14.0.6 (ORCJIT, znver3)
Threads: 69 on 24 virtual cores
I also replicated this on my own machine on master.
julia> Meta.parse("function f(s, price)\n @show f\n f = s * price\nend")
:(function f(s, price)
#= none:1 =#
#= none:2 =#
#= none:2 =# @show f
#= none:3 =#
f = s * price
end)
julia> @code_lowered f(2, 3)
CodeInfo(
1 ─ value = f
│ %2 = f
│ %3 = Base.repr(%2)
│ Base.println("f = ", %3)
│ value
│ %6 = s * price
│ f = %6
└── return %6
)
julia> @code_typed f(2, 3)
CodeInfo(
1 ─ $(Expr(:throw_undef_if_not, :f, false))::Any
└── unreachable
) => Union{}
Metadata
Metadata
Assignees
Labels
No labels