objectionary / objectionary/lints

`wrong-sprintf-arguments` rule ineffective due to outdated `Φ.txt.sprintf` reference

Open
#1,355 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug good-title
Dominant language
Java
Stars
14
Forks
39
Avg merge
22h 54m
Merged PRs (30d)
90

Description

wrong-sprintf-arguments looks for an object that current EO does not have, so the rule can never fire.

src/main/resources/org/eolang/lints/misc/wrong-sprintf-arguments.xsl:36:

<xsl:for-each select="//o[@base='Φ.txt.sprintf']">

There is no txt package in objectionary/eo any more, and no object called sprintf anywhere in the runtime. Formatting lives in eo-runtime/src/main/eo/string/printf.eo and is reached as a method on the format string, so in XMIR it appears as a dispatch rather than as a package-level base:

$ grep -rl "txt.sprintf" eo-runtime/target/eo/1-parse/
(nothing)

$ grep -o 'base="[^"]*printf[^"]*"' eo-runtime/target/eo/1-parse/string/printf.xmir
base=".printf"

Thirteen files in the runtime alone use .printf, and none of them can be checked by this rule.

The three defects it knows how to report — more than two arguments on lines 53-56, a second argument that is not a well-formed Φ.tuple on line 93, and a tuple whose length disagrees with the format template on line 111 — are all still worth reporting. They simply have no subject: the rule matches a base string that stopped being emitted when txt.sprintf was replaced.

Adapting it means matching the dispatch instead of the base, and moving the format string from the first argument to the receiver:

<xsl:for-each select="//o[@base='.printf']">

with the argument indices shifted by one, since "fmt".printf (* args) puts the template on the receiver and leaves exactly one argument — the tuple — where the old form had two. That also simplifies the arity check: the old "only 2 arguments" rule becomes "only 1".

Worth confirming against a current XMIR before the change lands, since the receiver of a .printf dispatch is emitted as a preceding sibling rather than as a child, so the format string has to be reached through that sibling rather than through o[1].

Contributor guide

No contributing guide indexed for this repository

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 with src/main/resources/org/eolang/lints/misc/wrong-sprintf-arguments.xsl and inspect current XMIR for the .printf dispatch in eo-runtime/target/eo/1-parse/string/printf.xmir. Confirm how the receiver and tuple arguments are represented, then update the rule while preserving its three reported defects. Done means current .printf usages are checked instead of ignored.

Written by the indexing model from the issue text.

Assessment

Tech stack
xml
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.