Debugger not stopping inside open do blocks

Using VSCode with latest Julia ext and Julia 1.9.4

Consider the following example:

    current_files = 0
    n_markets = 0

    open("report.log", "w") do fpReport
        println(fpReport, "CHOOSER log with IS_n=$(is_n)  OOS1_n=$(oos1_n)  Reps=$(n_reps)")

        open(file_list_names, "r") do file
            for file_path in eachline(file)
                current_files += 1

                if current_files > size(market_dates, 1)
                    market_dates, market_data, current_sizes = resize_market_files!(market_dates, market_data, current_sizes, current_files)
                end
          end
     end
end

Stopping on anything outside the open do blocks works fine, otherwise any breakpoints inside get ignored by the debugger… this is quite annoying I assume it’s a bug of some sorts ?

This may or may not be related:

The vscode debugger compiles all modules except main by default, this makes the debugger faster but also disables the debugger from reaching those parts of the stack.
https://www.julia-vscode.org/docs/stable/userguide/debugging/#Settings-to-speed-up-the-debugger

Well my code is just a random script so its not in a module, it should be falling under Main. But also keep in mind the debugger does work, it just doesnt work within the open do blocks it works before and outside them.

Yes, my thought was that the open function is not in the Main module, and thus anything run inside it, such as the do block, might not be interpreted. But I’m not sure, and not at the computer right now so can’t test.

1 Like

Is this do block at the top-level? If so, Julia may regard each run of the do block as a distinct function. If it were within a function, then Julia would know it is the same function everytime.

julia> identity() do
       end
#3 (generic function with 1 method)

julia> identity() do
       end
#5 (generic function with 1 method)

julia> identity() do
       end
#7 (generic function with 1 method)

julia> f() = identity() do
       end
f (generic function with 1 method)

julia> f()
#9 (generic function with 1 method)

julia> f()
#9 (generic function with 1 method)
1 Like

I rewrote mine to actually take a closure and it also didnt work, so does that mean debugger doesn’t work in anonymous functions :frowning:

Above is the repro, i dont know if this is considered a debugger bug or whatever, but im using basic language constructs and a trivial hello world essentially and it doesn’t work without gotchas :frowning:

I’m pretty sure this is the case as well. To confirm, one can add "-Base." to the list of excluded modules per that VS Code docs link and open should no longer be excluded.