Skip to content

Typo in Quality::ceilOut<TAmounts> template: undefined identifier ceil_TAmounts_helper #8036

Description

@Krypto-Whitehat

Summary

While reading Quality.h I noticed a typo in the templated overload of Quality::ceilOut<TAmounts<In, Out>>: it calls ceil_TAmounts_helper(...), but the private helper is named ceilTAmountsHelper (no underscores). The three sibling templates (ceilIn, ceilInStrict, ceilOutStrict) all call the correctly spelled ceilTAmountsHelper.

Location

include/xrpl/protocol/Quality.h, line 355:

template <class In, class Out>
TAmounts<In, Out>
Quality::ceilOut(TAmounts<In, Out> const& amount, Out const& limit) const
{
    // Construct a function pointer to the function we want to call.
    static constexpr Amounts (Quality::*kCeilOutFnPtr)(Amounts const&, STAmount const&) const =
        &Quality::ceilOut;

    return ceil_TAmounts_helper(amount, limit, amount.out, kCeilOutFnPtr);  // <-- typo
}

The correctly spelled helper is declared around line 222 and defined around line 307 (Quality::ceilTAmountsHelper).

Why the build is not broken today

This is latent dead code: the template is never instantiated anywhere in the codebase. The existing callers resolve to the non-template overload Quality::ceilOut(Amounts const&, STAmount const&):

  • src/test/protocol/Quality_test.cpp:65 - the test helper constructs Amounts (a pair of STAmount), so it picks the STAmount overload.
  • src/test/app/AMMCalc_test.cpp:234 - steps is std::vector<std::pair<Amounts, bool>> (line 49), so amts is again Amounts, not TAmounts<IOUAmount, IOUAmount>.

Since template code is only type-checked at instantiation, the misspelled name goes unnoticed until someone actually calls ceilOut with TAmounts<In, Out> arguments, at which point they get a confusing compile error about an undefined identifier.

Impact

None at runtime. This is purely a code quality issue. It removes a trap for future callers of the typed (IOUAmount / XRPAmount) ceilOut overload.

Suggested fix

One word rename:

-    return ceil_TAmounts_helper(amount, limit, amount.out, kCeilOutFnPtr);
+    return ceilTAmountsHelper(amount, limit, amount.out, kCeilOutFnPtr);

Optionally, a small unit test that instantiates ceilOut<TAmounts<IOUAmount, IOUAmount>> (mirroring the existing ceilIn tests) would prevent this class of typo from regressing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions