Skip to content

Record where thunks actually created#58

Merged
oxinabox merged 2 commits intomasterfrom
ox/thunkwhere
Oct 23, 2019
Merged

Record where thunks actually created#58
oxinabox merged 2 commits intomasterfrom
ox/thunkwhere

Conversation

@oxinabox
Copy link
Member

Is this enough to close #57 ?

Should I test this? Maybe can throw error, then access the backtrack as a string,
and then make sure the right file name occurs?

Before

julia> demo_pb() = @thunk(error("no"))
demo_pb (generic function with 1 method)

julia> extern(demo_pb())
ERROR: no
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] (::var"#15#16")() at /Users/oxinabox/JuliaEnvs/ChainRulesWorld/ChainRulesCore.jl/src/differentials.jl:216
 [3] (::Thunk{var"#15#16"})() at /Users/oxinabox/JuliaEnvs/ChainRulesWorld/ChainRulesCore.jl/src/differentials.jl:223
 [4] extern(::Thunk{var"#15#16"}) at /Users/oxinabox/JuliaEnvs/ChainRulesWorld/ChainRulesCore.jl/src/differentials.jl:224
 [5] top-level scope at REPL[12]:1

After

julia> extern(demo_pb())
ERROR: no
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] (::var"#13#14")() at ./REPL[9]:1
 [3] (::Thunk{var"#13#14"})() at /Users/oxinabox/JuliaEnvs/ChainRulesWorld/ChainRulesCore.jl/src/differentials.jl:232
 [4] extern(::Thunk{var"#13#14"}) at /Users/oxinabox/JuliaEnvs/ChainRulesWorld/ChainRulesCore.jl/src/differentials.jl:233
 [5] top-level scope at REPL[10]:1

Note that in the real use case when not testing it in the REPL
will whow a filename and line number rather than
[2] (::var"#13#14")() at ./REPL[9]:1

@nickrobinson251
Copy link
Contributor

nickrobinson251 commented Oct 23, 2019

Made you a label 🏷 😀

@nickrobinson251
Copy link
Contributor

I really like this. Just needs tests :)

@nickrobinson251 nickrobinson251 self-requested a review October 23, 2019 12:54
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.

Make it easier to track down errors that occur in a thunk

2 participants