Skip to content

Commit

Permalink
relax non-strict case a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnMount committed Jul 22, 2017
1 parent d6a3b21 commit e3d83fb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions R/let.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,19 @@ prepareAlias <- function(alias, strict) {
nulls <- vapply(names(alias), is.null, logical(1)) |
vapply(alias, is.null, logical(1))
alias <- alias[!nulls]
# confirm alias is an invertable mapping strings to strings
if (length(unique(names(alias))) != length(names(alias))) {
stop('wrapr::prepareAlias alias keys must be unique')
}
if (length(unique(as.character(alias))) != length(alias)) {
stop('wrapr::prepareAlias alias values must be unique')
if(strict) {
# confirm alias is an invertable mapping strings to strings
if (length(unique(as.character(alias))) != length(alias)) {
stop('wrapr::prepareAlias alias values must be unique')
}
}
if ('.' %in% c(names(alias),as.character(alias))) {
stop("wrapr::prepareAlias can not map to/from '.'")
if(strict) {
if ('.' %in% c(names(alias),as.character(alias))) {
stop("wrapr::prepareAlias can not map to/from '.'")
}
}
for (ni in names(alias)) {
if (is.null(ni)) {
Expand Down Expand Up @@ -291,7 +295,7 @@ letprep_lang <- function(alias, lexpr) {
#' @param expr block to prepare for execution.
#' @param ... force later arguments to be bound by name.
#' @param subsMethod character substitution method, one of c('langsubs', 'stringsubs', 'subsubs').
#' @param strict logical if TRUE names must be valid un-quoted names.
#' @param strict logical if TRUE names and values must be valid un-quoted names, not dot, and unique values.
#' @param eval logical if TRUE execute the re-mapped expression (else return it).
#' @param debugPrint logical if TRUE print debugging information when in stringsubs mode.
#' @return result of expr executed in calling environment (or expression if eval==FALSE).
Expand Down
2 changes: 1 addition & 1 deletion man/let.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e3d83fb

Please sign in to comment.