Skip to content

Commit

Permalink
Fix backwards compatibility with R4.1 (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrjohns authored Jul 10, 2024
1 parent 8fd9eb4 commit 970fe86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel'}
- {os: ubuntu-latest, r: '4.1'}
# - {os: ubuntu-latest, r: '3.6'}

env:
Expand Down
5 changes: 5 additions & 0 deletions inst/include/cpp11/environment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ class environment {
proxy operator[](const std::string& name) const { return operator[](name.c_str()); }

bool exists(SEXP name) const {
#if R_VERSION >= R_Version(4, 2, 0)
return safe[R_existsVarInFrame](env_, name);
#else
SEXP res = safe[Rf_findVarInFrame3](env_, name, FALSE);
return res != R_UnboundValue;
#endif
}
bool exists(const char* name) const { return exists(safe[Rf_install](name)); }

Expand Down

0 comments on commit 970fe86

Please sign in to comment.