r-lib / rlang

Low-level API for programming with R
https://rlang.r-lib.org
Other
502 stars 139 forks source link

is_syntactic_literal() returns TRUE in the presence of attributes. #1684

Open moodymudskipper opened 8 months ago

moodymudskipper commented 8 months ago
x <- 1
attr(x, "foo") <- 42
rlang::is_syntactic_literal(x)
#> [1] TRUE

Created on 2024-01-23 with reprex v2.0.2

I believe this contradicts the given definition, though the definition is a bit ambiguous :

is_syntactic_literal() is a predicate that returns TRUE for the subset of literals that are created by R when parsing text (see parse_expr()): numbers, strings and NULL. Along with symbols, these literals are the terminating nodes in an AST.