Skip to content

Wrong body output when a closure is defined of the first line of the method #50

@KristofferC

Description

@KristofferC
julia> function main()
           todB(x) = 10*log10(x)
           println("100x is $(todB(100)) dB.")
       end
main (generic function with 1 method)

julia> CodeTracking.definition(String, @which main())
("    todB(x) = 10*log10(x)", 2)

Which is just the closure defined inside the method that we are querying the body for.
If we add something before the closure:

julia> function main()
           foo
           todB(x) = 10*log10(x)
           println("100x is $(todB(100)) dB.")
       end
main (generic function with 1 method)

julia> CodeTracking.definition(String, @which main())
("function main()\n    foo\n    todB(x) = 10*log10(x)\n    println(\"100x is \$(todB(100)) dB.\")\nend", 1)

Then we get the full body of the method we want.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions