Repository navigation
count special module methods once per name for completion - #1530
Open
kevinushey wants to merge 1 commit into
Open
kevinushey wants to merge 1 commit into
kevinushey wants to merge 1 commit into
Conversation
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 #1529.
class_<T>::complete()(behind tab completion on module objects) sizes its output as the number of method names minusspecials, butAddMethod()incrementedspecialsonce per overload of a[-prefixed method. With[[overloaded, the last ordinary method went missing from the completions. If the class had no ordinary methods, the subtraction underflowed and the loop ran past the end of the method map. See #1529 for the reprex.Change (
inst/include/Rcpp/module/class.h,class_::AddMethod): incrementspecialsonly when a new method name is inserted, so it counts names, which is whatcomplete()assumes. This also keeps the count right for methods copied in byderives(), which go throughAddMethod()as well.Tests (
inst/tinytest/test_module.R, classes added tocpp/Module.cpp):ModuleBracketsoverloads[[and has an ordinary method and a field: completion givesc("total( ", "value"), and[[still dispatches.ModuleBracketsOnlyoverloads[[and has only a field: completion gives"value".Verification:
"scale"andattempt to set index 0/0 in SET_STRING_ELTagainst current master, and"total( " "scale"and"scale"against this branch.test_module.Rstops with the sameSET_STRING_ELTerror. On this branchtest_module.R(48/48),test_modref.R,test_expose_class.Randtest_module_client_package.Rpass withRunAllRcppTests=yes RunVerboseRcppTests=yes(R 4.6.1, macOS).Checklist
R CMD checkstill passes all tests (module test files run locally as above)