Skip to content

Fix two latent bugs in export docs and hot-path label parsing - #11

Open
EmilHvitfeldt wants to merge 2 commits into
mainfrom
fix-include-docs-and-label-parsing
Open

Fix two latent bugs in export docs and hot-path label parsing#11
EmilHvitfeldt wants to merge 2 commits into
mainfrom
fix-include-docs-and-label-parsing

Conversation

@EmilHvitfeldt

Copy link
Copy Markdown
Member

Two unrelated bugs found while auditing debrief's output for machine readability, both of which bite a user following the documentation.

pv_to_json() and pv_to_list() documented an include = "callers" option that was never wired up, so using it errored in match.arg(). It can't be implemented as-is, since pv_callers() needs a function name that a whole-profile export has no way to supply, so the docs now match reality.

Separately, pv_print_hot_paths() used a greedy regex to strip the " (file:line)" suffix off a stack entry, which also swallowed any part of the label after an earlier " (". Labels like if (x > 1) came back as if, and that truncated name feeds the pv_focus(p, "...") next-step suggestion, so the printed advice could name a function that doesn't exist.

The roxygen for pv_to_json() and pv_to_list() advertised "callers" as
an include option, but it was absent from both the default vector and the
function body, so following the docs errored in match.arg().

It cannot be implemented as-is: pv_callers() requires a function name, and
a whole-profile export has none to supply. Removed from the docs instead,
with a test asserting the documented set matches what is actually accepted.
pv_print_hot_paths() stripped the trailing " (file:line)" from a stack
entry with sub(" \\(.*\\)$", "", x). The greedy .* begins at the first
" (" in the string, so any label containing a space before an open paren
lost that part too:

  "if (x > 1) (file.R:3)"  ->  "if"

The truncated name then fed is_user_function() and the pv_focus(p, "...")
next-step suggestion, which could name a function that does not exist.

Extracted strip_location() into utils.R, anchored on the file:line shape,
which the location always has and a label never does.
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.

1 participant