-
Notifications
You must be signed in to change notification settings - Fork 985
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
typeorder for LGLSXP and RAWSXP in src/init.c is in conflict with R's coercion rules #4172
Comments
That example is only with 0 in |
Ah, I hadn't realised that base R's coercion rules differed depending on the value of the raw, nor that a design decision had been made here. I'm happy for the issue and correspondign PR to be closed, I agree that it doesn't make sense to downcast the non-zero raw values to TRUE. |
Thanks for the explanation Matt, let's add something to that effect as a comment there -- I looked around for an explanation of the ordering there before recommending to try switching but didn't find one |
Copying from a discussion chain with @MichaelChirico in #4144 :
In src/init.c the type order is laid out as follows:
The order of LGLSXP and RAWSXP are in conflict with R's coercion rules:
As you can see, the raw is coerced to logical, not the other way round as listed in src/init.c
I believe the coercion rules work this way because a logical vector may contain
NA
, whereas raw vectors cannot:Changing the order of LGLSXP and RAWSXP in typeorder has minimal impact, breaking only the following tests: 2006.1, 2006.2, and 2129.
These tests all related to the rbind/rbindlist functionality. Tests 2006.1 and 2006.2 are a simple fix: they simply expect the wrong output: when the typeorder is changed,
rbindlist(..., fill = TRUE)
with missing raw colums are now filled withNA
in line with the functionality for all other column types, rather than00
as is in the expected test output. Its not clear to me why 2129 fails, as the input data.tables do not contain raw columns, but the test is for rbind(), so this would take a little debugging.The text was updated successfully, but these errors were encountered: