Giter Club home page Giter Club logo

Comments (9)

lionel- avatar lionel- commented on July 28, 2024

Maybe winch should provide a function that returns a list of backtraces and locations of insertions and let rlang include it.

from winch.

DavisVaughan avatar DavisVaughan commented on July 28, 2024

I think the error_frame column in the rlang traceback data frame isn't being added in the winch traceback. Is that a new part of the rlang traceback?

If I follow the path of the original error through then I get to winch:::insert_native_chunk() where it actually does the modification of the rlang traceback object (which is itself a data frame). Everything looks correct except for the fact that the rlang traceback object has an extra error_frame column.

i.e. here is the original trace data frame and the new trace data frame that winch builds

Browse[5]> as.data.frame(trace)
                                                                                                call parent visible namespace scope error_frame
1                                 vctrs::num_as_location(-5, 4, oob = "extend", negative = "ignore")      0    TRUE     vctrs    ::        TRUE
2 stop_internal_c_lib(file = file, line = line, call = call, message = message, ,     frame = frame)      0   FALSE     rlang   :::       FALSE
3                                      abort(message, call = call, .internal = TRUE, .frame = frame)      2   FALSE     rlang    ::       FALSE
Browse[5]> new
                                                                                                call parent visible namespace scope
1                                 vctrs::num_as_location(-5, 4, oob = "extend", negative = "ignore")      0    TRUE     vctrs    ::
2                                                                                  ffi_as_location()      1    TRUE /vctrs.so    ::
3                                                                             vec_as_location_opts()      2    TRUE /vctrs.so    ::
4                                                                                  int_as_location()      3    TRUE /vctrs.so    ::
5                                                                             rlang_stop_internal2()      4    TRUE /rlang.so    ::
6                                                                                 stop_internal_cb()      5    TRUE /rlang.so    ::
7                                                                                    r_exec_mask_n()      6    TRUE /rlang.so    ::
8 stop_internal_c_lib(file = file, line = line, call = call, message = message, ,     frame = frame)      7   FALSE     rlang   :::
9                                      abort(message, call = call, .internal = TRUE, .frame = frame)      8   FALSE     rlang    ::

If I just hack the result of insert_native_chunk() with new$error_frame <- FALSE then I get a traceback again

from winch.

lionel- avatar lionel- commented on July 28, 2024

I think it'd be better if winch did not modify rlang backtraces.

from winch.

DavisVaughan avatar DavisVaughan commented on July 28, 2024

I agree with your suggestion about winch returning backtraces and locations and then letting rlang handle updating the traceback. I was just trying to narrow down exactly what the problem was 😛. If rlang handles the backtrace insertion then it is free to tweak the internal structure of the backtrace object without worrying about winch issues like this one.

from winch.

krlmlr avatar krlmlr commented on July 28, 2024

How do we handle this in rlang for now? I've been a bit out of touch with winch, but I need to do a release today and can work on improvements while I'm at it.

from winch.

lionel- avatar lionel- commented on July 28, 2024

How do we handle this in rlang for now?

Sorry I'm not sure what you mean.

from winch.

krlmlr avatar krlmlr commented on July 28, 2024

Missed the PR link, I now see it's been dealt with already. I'll fix here and PR in rlang then.

from winch.

krlmlr avatar krlmlr commented on July 28, 2024

Thanks. IIUC, you'd rather reimplement this functionality in rlang? I have tweaked winch_trace_back(), it now contains all the data necessary to do the interweaving of the stack traces. Would you like to move winch_add_trace_back() to rlang and adapt, do you need help with that?

from winch.

lionel- avatar lionel- commented on July 28, 2024

yup we could do that. On the other hand I'd like to improve extensibility / backtrace interop. But we could start from rlang for now and move back to winch later on. If you could draft the hook, that'd be great, thanks!

from winch.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.