An answer nobody reads, arguments in the wrong parameters: unused-answer from measured data, misplaced-argument from names #137
Loading…
Reference in a new issue
No description provided.
Delete branch "unread-answers"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Based on
values-asked-everywhere(#136), and contains it: the diff shown is this piece alone.Two more of the kinds of bug the study in #131 found in an adopter's history and today's checker is silent on. Each of these passed
tscstrict,safe-ts check --deny-warningsand oxlint:Rust has
#[must_use]for the first. For the second, every type fits, so TypeScript is content; only the names say what happened.Two rules
unused-answer(error): a statement that calls something whose only point is its answer.answerssection in the API maps: a script calls every member of the language map on sample receivers and arguments and keeps the 875 that answered something and changed neither receiver nor arguments. A test measures again and fails when the list differs. The 235 it leaves out are listed with the reason (they changed something, answer nothing, or belong to iterators, weak collections and promises, whose effects a snapshot cannot show).encodeInto,Atomics.compareExchange,readSync,confirm,prompt), each chosen by how real packages treat the answer.Map#delete,RegExp#test,writeSyncandReflect.setare out: their answer is dropped on purpose too often (RegExp#test383 times in installed packages, forlastIndex).JSON.parse(text);) is the failure rules', since it may be made for its throw.void expr;says the drop is meant. No quick fix: whether the answer was meant to be assigned or returned is not the checker's to guess.misplaced-argument(warning): two or more arguments whose names are the names of other parameters of the callee, shifted the same distance or swapped in pairs, where the parameter types are the same as a call sees them (readonly,Readonly<T>andMut<T>taken off). Names are read throughpos.x,mut(x)and aconstread once; methods, constructors and calls across files are covered. Exempt: both orders in one function (ranks(a, b) || -ranks(b, a)), a function calling itself, built-in signatures (the maps carry no parameter names).The oxlint preset now names
no-unused-expressions, which owns the same mistake written asc ? a.trim() : b.trim();orc && a.trim();. It fired only through oxlint's default category.Evidence
map.get(k)?.name, on the page). Receivers are found through a parameter, a member, a loop variable, an element by index, a field, a chain, a template literal, anewwritten in place.push,sort,reverse,splice,pop, a set'saddanddelete, a map'sset,forEach,Object.freeze, an iterator'snext(), a global pattern'sexec.clamp(min, value, max), across files, destination and source, throughmut(...)), and all 11 correct ones are silent, including a reversed comparator andMath.atan2(y, x). The first round missed destination and source because it wanted both parameter types written identically; fixed.assertNever(x)).encode-into-uncheckedandargument-shift-after-insertare closed, each by its rule alone, and a new class for a plain dropped answer was added and closed. 16 of 99 escape.constthe query does not follow) and two lines for quoting a callee with its parentheses.set.add(x)becauseaddis also a method of another class.What turns red on upgrade
voidin front if the drop is meant.no-unused-expressionsis an error where it was a warning.For the owner to decide
set-add-counted-twicestays open. No rule can close it honestly: in the real fix the function still returnstrueafter an unconditionaladd, and the repair went into the caller. What would close it is a small helper in std,insert(set, value): boolean, which says whether the value was new. Not added: an addition to std is yours to make.What stays unseen
URLSearchParams#get): only the language map is measured.label(name).trim();).misplaced-argument: one argument out of place alone; names that do not match the parameter (pxforx); built-in signatures.new Date(n).toISOString()can throw and the failure rules do not say so (older than this piece).Created with Claude Opus 5.5 (implementation and the merges) and Claude Fable 5.2 (review, acceptance tests and the last merge) in Claude Code.