op_spec() returns nullptr for the 17 operator aliases that op_key(), apply() and the generated functions accept

Open Beginner friendly
#348 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp, rust

Research direction

Start in ops.hpp at op_spec() (around line 6305) and inspect how it searches kOps; compare that with Session::op_key() and the manifest aliases. Run the supplied C++ reproduction and check op_spec() for all 17 aliases. Done means each alias returns its canonical operator spec, including its arity fields, while canonical-name lookup still works.

Written by the indexing model from the issue text.

Description

area/api-bindings good first issue help wanted kind/contract severity/4-minor

op_spec() returns nullptr for all 17 operator aliases (bessel_j, lambert_w, fresnel_s, ...), although the same names are accepted by apply(), resolved by Session::op_key() and exported as documented functions — so the table says "not registered" about a name the library registers.

// repro.cpp
#include <cstdio>
#include "rssn/client.hpp"
#include "rssn/ops.hpp"
using namespace rssn::client;
int main() {
  Session s; const auto x = s.sym("x");
  std::printf("op_spec(bessel_j)   = %s\n", op_spec("bessel_j")   ? op_spec("bessel_j")->name   : "nullptr");
  std::printf("op_spec(besselj)    = %s\n", op_spec("besselj")    ? op_spec("besselj")->name    : "nullptr");
  std::printf("apply(bessel_j)     = %s\n", s.apply("bessel_j", {x, s.integer(1)}).text().c_str());
  auto k = Session::op_key("bessel_j");
  std::printf("op_key(bessel_j)    = %s/%s\n", k.rule_set.c_str(), k.name.c_str());
}

Actual output (twice, identical):

op_spec(bessel_j)   = nullptr
op_spec(besselj)    = besselj
apply(bessel_j)     = besselj(x, 1)
op_key(bessel_j)    = special/besselj

The other 16 affected names: airy_ai, airy_ai_prime, airy_bi, airy_bi_prime, anger_j, bessel_i, bessel_k, bessel_y, chebyshev_t, chebyshev_u, erfc_inv, fresnel_c, fresnel_s, lambert_w, lambert_w_m1, weber_e. All are listed in the manifest's aliases field, all have a generated function in ops.hpp (e.g. inline Term airy_ai(const Term &a0) { return airyai(a0); }, ops.hpp:70925), and Session::op_key resolves every one of them to its canonical name.

Why it is wrong: op_spec is documented as "The spec of name, or nullptr when the name is not registered" (ops.hpp:6305) and the README advertises it as the way to look an operator up before calling it. Code that validates a name — if (!op_spec(name)) throw std::invalid_argument(name); — rejects 17 names that work, and a caller cannot read min_arity/max_arity for them.

Mechanism: kOps only holds canonical names, while aliases exist solely as thin wrapper functions, and op_spec binary-searches kOps with strcmp (ops.hpp:6305-6314), so an alias name can never match. Either add the aliases to kOps (pointing at the canonical spec) or resolve them before the search, the way op_key already does.

rssn 0.3.0, C++ client (header-only) over the release C library, Windows x86_64.

Dominant language
Rust
Stars
36
Forks
3
Avg merge
14h 51m
Merged PRs (30d)
29

Getting set up

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 Apich-Organization/rssn

All issues in Apich-Organization/rssn

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.