Skip to content

Improve code prevenance for @autoreleasepool functions - #73

Merged
maleadt merged 1 commit into
JuliaInterop:mainfrom
christiangnrd:provenance
Jun 3, 2026
Merged

maleadt merged 1 commit into
JuliaInterop:mainfrom
christiangnrd:provenance

Conversation

@christiangnrd

Copy link
Copy Markdown
Contributor

This has bothered me for a while since it makes error messages much harder to parse. May also fix codecov not picking up coverage of the function definition line if annotated with @autoreleasepool.

test.jl
using ObjectiveC
ObjectiveC.@autoreleasepool autothrowequal() = error()
ObjectiveC.@autoreleasepool function autothrowfunc()
    error()
end
function autothrowblock()
    ObjectiveC.@autoreleasepool error()
end

Old:

julia> include("test.jl"); methods(autothrowequal)
# 1 method for generic function "autothrowequal" from Main:
 [1] autothrowequal()
     @ ~/.julia/dev/ObjectiveC/src/foundation.jl:632

julia> methods(autothrowfunc)
# 1 method for generic function "autothrowfunc" from Main:
 [1] autothrowfunc()
     @ ~/.julia/dev/ObjectiveC/src/foundation.jl:644

julia> methods(autothrowblock)
# 1 method for generic function "autothrowblock" from Main:
 [1] autothrowblock()
     @ ~/.julia/dev/ObjectiveC/test.jl:6

New:

julia> include("test.jl"); methods(autothrowequal)
# 1 method for generic function "autothrowequal" from Main:
 [1] autothrowequal()
     @ ~/.julia/dev/ObjectiveC/test.jl:2

julia> methods(autothrowfunc)
# 1 method for generic function "autothrowfunc" from Main:
 [1] autothrowfunc()
     @ ~/.julia/dev/ObjectiveC/test.jl:3

julia> methods(autothrowblock)
# 1 method for generic function "autothrowblock" from Main:
 [1] autothrowblock()
     @ ~/.julia/dev/ObjectiveC/test.jl:6

@codecov

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@8dc02e2). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/foundation.jl 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #73   +/-   ##
=======================================
  Coverage        ?   73.55%           
=======================================
  Files           ?       13           
  Lines           ?     1006           
  Branches        ?        0           
=======================================
  Hits            ?      740           
  Misses          ?      266           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@maleadt

maleadt commented Jun 3, 2026

Copy link
Copy Markdown
Member

I guess the only disadvantage is that crashes from code inserted by the macro would now be misattributed to the source function and not the macro?

@christiangnrd

Copy link
Copy Markdown
Contributor Author

I threw in an error in NSAutoreleasepool(f) and it seems like the output is the same except for the function definition so it seems like it's still an improvement.

Old:

julia> autothrowfunc()
ERROR: 
Stacktrace:
 [1] error()
   @ Base ./error.jl:45
 [2] macro expansion
   @ ~/.julia/dev/ObjectiveC/src/foundation.jl:570 [inlined]
 [3] macro expansion
   @ ./lock.jl:376 [inlined]
 [4] ObjectiveC.Foundation.NSAutoreleasePool(f::var"#autothrowfunc##0#autothrowfunc##1")
   @ ObjectiveC.Foundation ~/.julia/dev/ObjectiveC/src/foundation.jl:565
 [5] autothrowfunc()
   @ Main ~/.julia/dev/ObjectiveC/src/foundation.jl:644
 [6] top-level scope
   @ REPL[2]:1

New:

julia> autothrowfunc()
ERROR: 
Stacktrace:
 [1] error()
   @ Base ./error.jl:45
 [2] macro expansion
   @ ~/.julia/dev/ObjectiveC/src/foundation.jl:570 [inlined]
 [3] macro expansion
   @ ./lock.jl:376 [inlined]
 [4] ObjectiveC.Foundation.NSAutoreleasePool(f::var"#autothrowfunc##0#autothrowfunc##1")
   @ ObjectiveC.Foundation ~/.julia/dev/ObjectiveC/src/foundation.jl:565
 [5] autothrowfunc()
   @ Main ~/.julia/dev/ObjectiveC/test.jl:3
 [6] top-level scope
   @ REPL[2]:1

@maleadt
maleadt merged commit 026a406 into JuliaInterop:main Jun 3, 2026
12 checks passed
@christiangnrd
christiangnrd deleted the provenance branch June 3, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants