ws-cleanup: type diagnostics 1109 -> 94 unique; lint gate against tools/lint_types_baseline.txt

ws/cleanup-types (merged before) annotated Types, init, core, codecs, containers, ops, host and the formats;
this commit fixes the rest in the modules ws-cleanup added (AudioOps, Resample, Vorbis / FLAC / Opus encoders).
tools/lint.sh now counts unique diagnostics (the analyzer printed every required src module twice: master's
'2499' was 1109 unique) and fails when the count rises above tools/lint_types_baseline.txt (94);
LINT_TYPES_UPDATE=1 lowers it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
4DBugandClaude Opus 5.5 committed 2026-10-31 11:30:29 -05:00
1 parent b77660343a
commit dca1130324
7 files changed
+39 -24

No files matched your search

+1 -1
View File
@@ -769,7 +769,7 @@ function Encode.encode(src: Source, opts: Options): (buffer?, string?)
local mbuf = buffer.create(bs * ch * mbytes)
local scale = POW[bps]
local maxv, minv = scale - 1, -scale
local X = table.create(ch)
local X: { { number } } = table.create(ch) :: any
for c = 1, ch do
X[c] = table.create(bs, 0)
end
+1 -1
View File
@@ -25,7 +25,7 @@ local floor = math.floor
-- encode(audio | decoder, opts) -> buffer | nil, Err
function Encode.encode(value: any, opts: Options?): (buffer?, Err.Err?)
local o = opts or {}
local o: Options = opts or {}
local src, serr = Pcm.source(value)
if not src then
return nil, serr
+3 -3
View File
@@ -604,7 +604,7 @@ function Encode.encode(src: Source, opts: Options): (buffer?, string?)
local plan = Mdct.new(N) :: Mdct.Plan
local win = Mdct.window("vorbis", N) :: { number }
-- input ring: per channel the samples of the current frame [k*1024 - 1024, k*1024 + 1024)
local frame = table.create(ch)
local frame: { { number } } = table.create(ch) :: any
for c = 1, ch do
frame[c] = table.create(N, 0)
end
@@ -617,8 +617,8 @@ function Encode.encode(src: Source, opts: Options): (buffer?, string?)
end
end
local blk = table.create(N, 0)
local X = table.create(ch)
local R = table.create(ch)
local X: { { number } } = table.create(ch) :: any
local R: { { number } } = table.create(ch) :: any
for c = 1, ch do
X[c] = table.create(N2, 0)
R[c] = table.create(N2, 0)
+8 -9
View File
@@ -208,7 +208,7 @@ local function run(st: State, limitOut: number, out: buffer?): (buffer, number)
st.histFrames = 0
st.base = base + histFrames
else
local nh = table.create((histFrames - drop) * ch)
local nh: { number } = table.create((histFrames - drop) * ch) :: any
table.move(hist, drop * ch + 1, histFrames * ch, 1, nh)
st.hist = nh
st.histFrames = histFrames - drop
@@ -251,7 +251,7 @@ function Resample.new(from: number, to: number, channels: number, opts: Options?
if type(channels) ~= "number" or channels < 1 or channels > 256 or channels ~= floor(channels) then
return nil, "bad channel count"
end
local q = QUALITY[(opts and opts.quality) or "medium"]
local q: { number }? = QUALITY[(opts and opts.quality) or "medium"]
if not q then
return nil, "quality must be low, medium or high"
end
@@ -260,12 +260,11 @@ function Resample.new(from: number, to: number, channels: number, opts: Options?
return nil, "cutoff must be 0.5 .. 1"
end
-- positions are exact integers: output j sits at input j * M / L (non-integer rates: to 1 / 1000 Hz)
local fi, ti = from, to
if from ~= floor(from) or to ~= floor(to) then
fi, ti = floor(from * 1000 + 0.5), floor(to * 1000 + 0.5)
end
local g = gcd(fi, ti)
local L, M = ti // g, fi // g
local scale = if from ~= floor(from) or to ~= floor(to) then 1000 else 1
local fi: number = floor(from * scale + 0.5)
local ti: number = floor(to * scale + 0.5)
local g: number = gcd(fi, ti)
local L: number, M: number = ti // g, fi // g
local exact = L <= MAX_EXACT
local phases = if exact then L else INTERP_PHASES
local st: State = {
@@ -348,7 +347,7 @@ function Resample.source(src: any, to: number, opts: Options?): (any, string?)
function out.read(self: any, n: number, dst: buffer?): (buffer, number)
n = floor(n)
while pendingFrames - pendingPos <= 0 and not ended do
local b, m = src:read(math.max(1024, floor(n * src.sampleRate / to) + 64), inTmp)
local b: buffer, m: number = (src :: any):read(math.max(1024, floor(n * src.sampleRate / to) + 64), inTmp)
inTmp = b
local r: buffer, k: number
if m <= 0 then
+6 -5
View File
@@ -207,7 +207,7 @@ local TO_STEREO: { [string]: { number } } = {
-- matrix(from, to) -> m[o][i]: output channel o = sum m[o][i] * input i
local function matrix(from: number, to: number): { { number } }
local m = table.create(to)
local m: { { number } } = table.create(to) :: any
for o = 1, to do
m[o] = table.create(from, 0)
end
@@ -220,7 +220,7 @@ local function matrix(from: number, to: number): { { number } }
local inL, outL = LAYOUT[from], LAYOUT[to]
if to < from and inL and outL and to <= 2 then
-- down to stereo (then mono = the average of the two)
local l, r = table.create(from, 0), table.create(from, 0)
local l: { number }, r: { number } = table.create(from, 0), table.create(from, 0)
local sl, sr = 0, 0
for i, sp in inL do
local w = TO_STEREO[sp] or { 0, 0 }
@@ -266,10 +266,11 @@ local function matrix(from: number, to: number): { { number } }
local o = outIdx[sp]
if o then
m[o][i] = 1
elseif to < from and outIdx.FL and outIdx.FR then
elseif to < from and outIdx.FL ~= nil and outIdx.FR ~= nil then
local w = TO_STEREO[sp] or { 0, 0 }
m[outIdx.FL][i] += w[1]
m[outIdx.FR][i] += w[2]
local fl, fr = outIdx.FL :: number, outIdx.FR :: number
m[fl][i] += w[1]
m[fr][i] += w[2]
end
end
if to < from then