Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a warning instead of an error for opts_current locking #2296

Merged
merged 6 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Negative numbers returned from inline R expressions lost their minus signs when formatted in the scientific notation (thanks, @fkohrt, #2288).

## MAJOR CHANGES

- `opts_current$set()` without `opts_current$lock(FALSE)` will trigger a warning instead of an error for now and it will become an error in future (#2296).

# CHANGES IN knitr VERSION 1.44

## NEW FEATURES
Expand Down
8 changes: 6 additions & 2 deletions R/defaults.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ new_defaults = function(value = list()) {
set2 = function(values) {
old = get(names(values), drop = FALSE)
if (length(values)) {
if (locked) stop(
# TODO: change warning() to stop() and no longer whitelist JuliaCall
if (locked && !identical(names(values), 'Jfig.cur')) warning(
'The object is read-only and cannot be modified. If you have to modify it ',
'for a legitimate reason, call the method $lock(FALSE) on the object before $set().'
'for a legitimate reason, call the method $lock(FALSE) on the object before $set(). ',
'Using $lock(FALSE) to modify the object will be enforced in future versions of knitr ',
'and this warning will become an error.',
immediate. = TRUE
)
defaults <<- merge(values)
}
Expand Down
Loading