stan-dev / stan-dev/math

check_range does ignore names argument

Open
#2,485 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
839
Forks
220
Avg merge
2d 4h
Merged PRs (30d)
14

Description

Description

The check_range error checking function does ignore the names argument and thereby it prevents good error messages.

Example

Here is the definition:

inline void check_range(const char* function, const char* name, int max,
                        int index, int nested_level, const char* error_msg) {
  STAN_NO_RANGE_CHECKS_RETURN;
  if (!((index >= stan::error_index::value)
        && (index < max + stan::error_index::value))) {
    [&]() STAN_COLD_PATH {
      std::stringstream msg;
      msg << "; index position = " << nested_level;
      std::string msg_str(msg.str());
      out_of_range(function, max, index, msg_str.c_str(), error_msg);
    }();
  }
}

The name should somehow be passed on. No??

Expected Output

Error messages should

Current Version:

v4.0.1

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.

Research direction

Start at the check_range definition shown in the issue and trace how it calls out_of_range. Pass the name through so the resulting range error includes it, then verify that the error message identifies the checked name.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.