Skip to content

Make is_syntactic_literal() more strict - #1824

Merged
lionel- merged 1 commit into
r-lib:mainfrom
jonthegeek:fix-1817-is_syntactic_literal
Sep 19, 2025
Merged

lionel- merged 1 commit into
r-lib:mainfrom
jonthegeek:fix-1817-is_syntactic_literal

Conversation

@jonthegeek

Copy link
Copy Markdown
Contributor

Add an attributes() check to is_syntactic_literal() to ensure that syntactic-literal-like objects such as factors and arrays are not treated as syntactic literals.

Fixes #1817.

Add an `attributes()` check to `is_syntactic_literal()` to ensure that syntactic-literal-like objects such as factors and arrays are not treated as syntactic literals.

Fixes r-lib#1817.
@jonthegeek

jonthegeek commented Sep 19, 2025 •

Copy link
Copy Markdown
Contributor Author

#1799 is really close to this. Would you like me to fix that in this same PR, or keep it separate? It will make it make sense to split integer and double off from character (possibly with a shared helper), so the structure of what I did here might change a bit. In any case it doesn't feel like it makes sense to work on the separate PR until this one is reviewed.

Edit: Technically character can remain as-is with just length(x) == 1, but it's probably technically better for it to also have the is.null(attributes(x)) check, and it feels like a shared helper is good for those in case anything else comes up along the same lines.

@lionel-
lionel- merged commit e5fee11 into r-lib:main Sep 19, 2025
11 checks passed
@lionel-

lionel- commented Sep 19, 2025

Copy link
Copy Markdown
Member

A second PR for the other fix would be great, thanks!

@jonthegeek
jonthegeek deleted the fix-1817-is_syntactic_literal branch September 19, 2025 17:42
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.

is_syntactic_literal() returns TRUE for arrays

2 participants