fix: do.call with non-syntactic function name breaks parsing (#335) - #357
Merged
Conversation
.parse_function converted a do.call() string function argument into a
call with parse(text = ...). That fails outright when the string names a
non-syntactic function, e.g. do.call("[<-", ...) in mlt::tmlt, aborting
node extraction for the whole package.
Use as.name() instead, which accepts any name.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
bburns632
force-pushed
the
fix/335-do-call-nonsyntactic-name
branch
from
September 1, 2026 04:29
7bcd872 to
0affccc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #335.
The bug
The error reported in #335 —
the condition has length > 1— was fixed by #331, which added the[1]subscript todeparse(x[[1]]). But{mlt}still fails to report, one line further down:mlt::tmltandmlt::dmltcalldo.call("[<-", ...).parse(text = "[<-")is a syntax error, since a bare replacement operator is not parseable as an expression:.parse_function()recurses over every expression in the package, so one such call aborts node extraction for the whole package. Those two functions are the only ones in mlt's namespace that trip it.The fix
Use
as.name()instead ofparse(text = ). The goal of this block is to turn a string naming a function into a symbol so the recursion can match it against the package namespace, andas.name()does that for any name, syntactic or not. For an ordinary name likedo.call("at_bats", ...)the result is unchanged.Tests
Two unit tests next to the existing
.parse_functiontests:do.callwith a plain string name — guards the Handle functions referenced by name as a string when using do.call() #302 behavior this block exists for, which had no direct unit test (only the baseballstats network fixture).do.callwith a non-syntactic name — the regression test for this issue. Confirmed non-vacuous: against unmodifiedR/FunctionReporter.Rit errors with exactly theunexpected '['message above.Verification
The reproducer from the issue now completes:
FunctionReporteron mlt yields 154 nodes / 152 edges, where it previously errored. Full default reports for{mlt}and{ggplot2}also render cleanly.Full local
devtools::test(): 250 pass, 2 fail. Both failures arecovr::package_coverage()errors on baseballstats (test-FunctionReporter-class.R:91,test-plotting.R:12). They are pre-existing and unrelated — I stashed the diff and reproduced the identical failures on cleanmain, and CI is green onmainat3c3457e(the commit this branches from). Local environment only; deferring to CI.🤖 Generated with Claude Code