Skip to content

Enable full compiler flag set (matches made/commons/regex) - #34

Merged
halotukozak merged 1 commit into
mainfrom
enable-full-compiler-flags
Aug 26, 2026
Merged

Enable full compiler flag set (matches made/commons/regex)#34
halotukozak merged 1 commit into
mainfrom
enable-full-compiler-flags

Conversation

@halotukozak

Copy link
Copy Markdown
Collaborator

Brings mcodec's project.scala up to the same //> using options set as made/commons/regex, including -Wsafe-init -Werror -Wunused:all.

Verified locally (JVM): full test suite passes clean with the new flags. Also confirmed -Wsafe-init does not hang here (unlike mrpc, where it's disabled for a documented reason) — 90s bound compile finished fine.

-Werror -Wunused:all surfaced 4 real warnings, fixed as follows:

  • src/mcodec/CborInput.scala (skipChunks): the outer major param and each chunk's own major type (cm, from reader.readInitial()) were both unused — meaning a chunk's major type is never checked against the container's. Marked both explicitly unused (@unused/_) rather than silently adding validation logic, and left a TODO comment describing the gap: worth a look — malformed CBOR with mismatched chunk major types inside an indefinite-length container is currently accepted rather than rejected. Not fixed here since it's a behavior decision, not a compiler-flag cleanup.
  • src/mcodec/Derivation.scala:11 (given self: MCodec[T] = deferred): flagged unused because -Wunused can't see that it's read via implicit search only after derivedRec's transparent inline body is expanded at call sites (needed for recursive/self-referential T). Suppressed with @nowarn rather than removed/renamed, to keep behavior identical — renaming it anonymous first (to test whether it was just the name) still triggered "unused local definition", confirming this isn't a naming issue.
  • src/mcodec/Derivation.scala:119 (summonFrom presence-check pattern): same class of inline/macro false positive, suppressed with @nowarn on the expression.
  • 3 unused test imports (ExtendedStdCodecsTest.scala, JavaHashSetIntTest.scala): removed, confirmed genuinely unused.
  • test/mcodec/IoContractExtTest.scala: -Wsafe-init rejected floatCases/tsCases/binCases as not-yet-initialized when captured by test(...) closures declared earlier in the class body. Converted to lazy val — standard fix for this pattern, no behavior change (values are still computed once, just on first access instead of at construction).

@halotukozak
halotukozak enabled auto-merge August 26, 2026 19:21
@halotukozak
halotukozak merged commit 5714061 into main Aug 26, 2026
7 checks passed
@halotukozak
halotukozak deleted the enable-full-compiler-flags branch August 26, 2026 19:24
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.

1 participant