Skip to content

fix: correct malformed type() checks (C7)#40

Merged
dsent merged 1 commit into
aldum:devfrom
Vadim1987:fix/c7-type-checks
Jul 4, 2026
Merged

fix: correct malformed type() checks (C7)#40
dsent merged 1 commit into
aldum:devfrom
Vadim1987:fix/c7-type-checks

Conversation

@Vadim1987

Copy link
Copy Markdown

Five type() guards across the codebase share one defect shape — the comparison ends up inside the type() call, or not binds to type() before the comparison — so the guard never does its job:

  1. table.is_array, table.flatten, table.odds (util/table.lua): not type(self) == "table" is always false, so the check reduces to not self, and passing any non-table scalar crashes on pairs instead of returning false/nil. These are reachable through analyze.lua and debug.lua.
    2 UserInputModel:set_error: type(errors[1] == "string") is type(boolean), always truthy, so the branch that converts non-string errors with tostring is dead and raw error tables are stored in a field annotated string[]. The display path happens to tostring elements anyway, which masks it today, but any other consumer of the field gets tables where strings are promised.
  2. is_lua_block (md/parser.lua): not type(t) == "table" never returns early; strings survive by accident (string indexing doesn't raise), other scalars would.
    All five become the intended type(x) ~= "table" / type(x) == "string" forms.
    The same pattern exists once more in the stringutils submodule (string.lua:241) — out of scope here, can be fixed upstream separately.

@dsent dsent requested a review from aldum July 2, 2026 19:57
@dsent dsent merged commit 7728158 into aldum:dev Jul 4, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants