CHECK_RANGE macro attempts to pass Rcomplex value to %f formatter

Open
#6,531 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
c, r
Domain
data

Research direction

Start with the CHECK_RANGE macro and its snprintf call, then reproduce the issue using the set() examples in the report. Trace how the Rcomplex value reaches the %f formatter and determine the intended warning wording; done means complex-to-integer assignment warnings accurately describe the value and existing behavior remains covered.

Written by the indexing model from the issue text.

Description

bug internals

Seen as part of #6530, where an ad hoc solution to use val.r instead of val is used to unblock that PR.

AFAICT this is not strictly a bug because snprintf() is currently doing this (using val.r) implicitly:

DT=data.table(a = 1:10)
set(DT, 2L, 'a', 1+2i)
# Warning message:
# In set(DT, 2L, "a", 1 + (0+2i)) :
#   1.000000 (type 'complex') at RHS position 1 either imaginary part discarded or real part truncated (precision lost) when assigning to type 'integer' (column 1 named 'a')

set(DT, 2L, 'a', 1+3i)
# Warning message:
# In set(DT, 2L, "a", 1 + (0+3i)) :
#   1.000000 (type 'complex') at RHS position 1 either imaginary part discarded or real part truncated (precision lost) when assigning to type 'integer' (column 1 named 'a')

set(DT, 2L, 'a', 0+3i)
# Warning message:
# In set(DT, 2L, "a", 0 + (0+3i)) :
#   0.000000 (type 'complex') at RHS position 1 either imaginary part discarded or real part truncated (precision lost) when assigning to type 'integer' (column 1 named 'a')

But I believe the error message is not correct/as helpful as it could be if constructed more carefully.

Dominant language
R
Stars
3.9k
Forks
1.1k
Avg merge
14h 4m
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Rdatatable/data.table

All issues in Rdatatable/data.table

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.