typed_python icon indicating copy to clipboard operation
typed_python copied to clipboard

fix typo in `StringType::cmpStatic`

Open tdp2110 opened this issue 3 years ago • 0 comments

Motivation and Context

A typo in StringType.cpp causes a logical error in StringType::cmpStatic

Approach

Fix the typo, remove the using namespace std directive. See the commit messages for more detail, included below

  • StringType.cpp: remove using namespace std directive

    As demonstrated in the previous commit, and as a general principle, the using namespace std directive can lead to surprising results and is not generally recommended.

    Remove it to avoid further similar bugs in the future.

  • StringType::cmpStatic: fix accidental reference to std::right

    Because of the using namespace std directive at the top of StringType.cpp, within StringType::cmpStatic, right is resolved to the function std::right, from the <ios> header, included indirectly by <iostream>. std::right, a function, is always non-null. The intention here was clearly to use the parameter right_data, not std::right.

    Fix that bug.

How Has This Been Tested?

Not tested.

Screenshots or console output (if appropriate)

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.

tdp2110 avatar Aug 13 '22 19:08 tdp2110