Skip to content

Keep S7 := ahead of rlang and data.table#718

Draft
t-kalinowski wants to merge 2 commits into
mainfrom
suppress-s7-warnings
Draft

Keep S7 := ahead of rlang and data.table#718
t-kalinowski wants to merge 2 commits into
mainfrom
suppress-s7-warnings

Conversation

@t-kalinowski

@t-kalinowski t-kalinowski commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #697.

This is one possible solution for making S7's := operator the search-path binding users get when S7 is attached, regardless of whether rlang or data.table is attached before or after it. The approach prevents attach-order-dependent masking and removes noisy := masking messages.

User-facing changes

  • S7::`:=` now wins on the search path when used with rlang or data.table.
  • Attaching S7 with rlang or data.table no longer emits := masking messages.
  • Explicit namespace access like rlang::`:=` and data.table::`:=` is unchanged.

Internal changes

  • Registers base conflictRules() excludes for := on rlang and data.table during S7 startup.
  • Marks S7's attached package environment as conflict-ok only when an existing := conflict needs to be silenced.
  • Adds subprocess regression coverage for both attach orders.

Comment thread R/compatibility.R
}

env <- as.environment(paste0("package:", pkgname))
env[[".conflicts.OK"]] <- TRUE

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should only ever apply this to S7 itself, and I think we can move it up to .onAttach() so we use it unconditionally when conflictRules() is not available.

Comment thread R/compatibility.R
Comment on lines +42 to +45
conflictRules <- get0("conflictRules", envir = baseenv(), inherits = FALSE)
if (is.null(conflictRules)) {
return(invisible())
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be clearer to use an explicit version here

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.

Fix rlang/data.table conflicts

2 participants