Skip to content

fix: mark every internal bool function nodiscard and check it - #276

Merged
siracozmen01 merged 1 commit into
mainfrom
fix/nodiscard-bools
Nov 5, 2026
Merged

siracozmen01 merged 1 commit into
mainfrom
fix/nodiscard-bools

Conversation

@siracozmen01

@siracozmen01 siracozmen01 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem

MUNI_NODISCARD marked every public function that returns a status, but no internal function returning bool. Many of those refuse something or give an answer the caller must act on:

  • the iterator checks (Load, RulesValid, muniCursorValid);
  • muniWriterFits and muniNormalizerAdd;
  • lookups and steps whose false leaves an out value unset.

A call that dropped one of these results went on past a refusal, and no compiler warned. Nothing kept a new bool function from being added unmarked either. The organization's .github v0.0.53 makes the family rule uniform and adds a check for it; this repository also still had the v0.0.51 copies of cmake/Testing.cmake and docs/internals/maul-conventions.md (#273).

Change

  • family_sync.py --write from .github v0.0.54 (b52e9f7), the latest, which for this repository equals v0.0.53. It writes tools/check_nodiscard.py and the v0.0.52 and v0.0.53 changes to cmake/Testing.cmake (the C23 check that MUNI_NODISCARD is not empty) and docs/internals/maul-conventions.md. This takes in ci: sync the family files to v0.0.52 #274, which this pull request replaces.
  • Every function returning bool that is declared in a header under src/, and every static one in a source file under src/, carries MUNI_NODISCARD: 57 declarations in 26 files, plain answers and lookups as well as refusals. None is in src/generated/.
  • src/overlap.h and src/writer.h reached no public header, so they now include maul-unicode/base.h for the macro. tools/modules.txt allows any public header.
  • tools/check.sh runs python3 tools/check_nodiscard.py --self-test and python3 tools/check_nodiscard.py in its rules step, and CI's family checks step runs both too, since that step lists each check itself.

The deliberate drops

None. With every bool marked, the linux-gcc-14 and linux-clang-20-asan builds (library, tools, samples, benchmarks and tests, with -Werror) report no dropped result, and the tree held no (void) cast on a call to any of these functions. The HarfBuzz adapter calls only the public API.

Verification

  • python3 tools/check_nodiscard.py passes, and its --self-test passes. In a copy of the tree, with the mark removed from muniWriterFits it names src/writer.h:72 and exits 1, and an indented bool declaration added to src/overlap.h is reported as one it does not read.
  • linux-gcc-14 builds clean and passes 13/13; linux-clang-20-asan builds clean and passes 13/13.
  • family_sync.py --check from v0.0.54: 0 differences.
  • tools/check.sh changed passes: the rules with the new check, format, clang-tidy in Release and Debug, and all 13 suites under linux-clang-20-asan.

Closes #275
Closes #273

@siracozmen01 siracozmen01 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review at 69fd004: ready. Read, not run.

The family files match .github v0.0.54 byte for byte. I fetched maul/files/tools/check_nodiscard.py, maul/files/cmake/Testing.cmake and maul/files/docs/internals/maul-conventions.md at the v0.0.54 tag and compared each with this head. diff finds no difference in any of the three. Testing.cmake goes 144bbe4..68163e3, the v0.0.52 blob pair. Its C23 check reads the column-0 #define MUNI_NODISCARD [[nodiscard]] at include/maul-unicode/base.h:72 and :76.

The marks.

  • The diff adds 57 MUNI_NODISCARD lines. Each replaces one removed bool declaration line, apart from the second line of muniCursorValid's wrapped parameters.
  • I read the shapes the family check has to parse:
    • static MUNI_ALWAYS_INLINE bool RulesValid( and Load( match as the library's macros.
    • The parameter line bool waiting) is neither a declaration nor a refusal.
    • The static inline header helpers (muniCursorValid, muniNormalizerAdd, muniWriterFits, muniOverlaps, In, IsWide and the rest) are all marked.
  • overlap.h and writer.h now include maul-unicode/base.h, the only way they reach the macro.
  • The check fails closed on any shape it does not read. Both check.sh and CI's family checks step run it with its self-test, so a declaration it missed would fail CI rather than pass.

No (void) sites. A plain fix (no !) is right at 1.x: no result changes.

@siracozmen01
siracozmen01 merged commit 695134c into main Nov 5, 2026
26 checks passed
@siracozmen01
siracozmen01 deleted the fix/nodiscard-bools branch November 5, 2026 03:14
@rawframe-release rawframe-release Bot mentioned this pull request Nov 5, 2026
siracozmen01 pushed a commit that referenced this pull request Nov 5, 2026
🤖 I have created a release *beep* *boop*
---


## [1.1.2](v1.1.1...v1.1.2) (2026-11-05)

### Fixed

- Every internal function that returns `bool` now carries
  `MUNI_NODISCARD`, so a compiler warns where the library would drop
  one of their answers, and `tools/check_nodiscard.py` keeps new ones
  marked. No call dropped one, so nothing a caller sees changes: same
  API, same behavior. The header tests now also check that
  `MUNI_NODISCARD` is not empty in C23
  ([#276](#276)).

No results change: the Unicode data is still 18.0.0 and
`MUNI_RESULTS_VERSION` stays 2, so stored normalized keys, skeletons
and verdicts from 1.1.1 stay valid.
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.

Internal functions returning bool are not nodiscard Sync the family files to .github v0.0.52

1 participant