Repository navigation
fix: CMTK0005 stays silent on an array with a constant zero in any dimension - #233
Merged
CaffeinatedCoder merged 2 commits intoOct 31, 2026
Merged
Conversation
…mension AnalyzeArrayCreation skipped an array only when every dimension was a constant 0. A multidimensional array is empty when any one dimension is, so new Plain[0, 2] held no default element and was reported. The check is now Any; stackalloc reads the same rule, where its one dimension made All and Any agree already. Input class (AIS): an array creation of a no-default struct, by rank and by which dimension is a constant zero. The new row covers rank 2 with the first, the second and both dimensions zero, a variable beside a literal zero and a named constant beside a variable, rank 3 with a zero in the middle and last, a jagged [0][], and two arrays with no zero dimension that still report. No sibling: the invocation forms take one length, where a zero is already skipped. Reverting the source fails the row: 8 reports where 2 are expected. Closes #227 Defect-Class: AIS Found-By: OR Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The zero check matched only a boxed int. An array dimension may be a long, uint or ulong, so new Plain[0L] was reported, and a stackalloc size is read from syntax with its type before the conversion to int, so stackalloc Plain[(byte)0], [(short)0] and ['\0'] were too. One IsZero now reads every integral constant, for the array creation, the stackalloc and the allocating calls alike. Found running #227's input class (an array creation by which dimension is a constant zero) across how the zero is written: int, long, uint, ulong, byte, short and char, in new, stackalloc, GC.AllocateArray and Array.Resize. The six that failed are the long and unsigned dimensions and the three stackalloc sizes. Seeding the int-only match back fails the row: 8 reports where 2 are expected. Refs #227 Defect-Class: AIS Found-By: VA Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 31, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #227
Problem
DefaultFilledCollectionAnalyzer.AnalyzeArrayCreationskipped an array only when every dimension was a constant0. A multidimensional array is empty when any dimension is, sonew Plain[0, 2]andnew Plain[2, 0], which hold no element, got CMTK0005.Change
DefaultFilledCollectionAnalyzer.cs:Anyin place ofAllfor the array creation; thestackallocpath reads the same rule (one dimension there, so no behaviour change).K05-a-zero-dimension-is-silentholds the new sentence.Found-By: VA, its own commit): the zero check matched only a boxedint, sonew Plain[0L],[0u, 2],[2, 0ul]andstackalloc Plain[(byte)0],[(short)0],['\0']were reported. OneIsZeronow reads every integral constant, for the array creation, the stackalloc and the allocating calls.### Fixed. A Warning that reports less needs no exception to decision 34.Tests
DefaultFilledCollectionAnalyzerTests.An_array_with_any_constant_zero_dimension_stays_silent, across the input class (an array creation, by rank and by which dimension is a constant zero):[0, 2],[2, 0],[0, 0],[n, 0],[none, n](a named constant),[2, 0, 2],[n, 2, 0]and a jagged[0][]silent;[2, 2]and[n, 1, 2]reported.A_zero_of_any_integral_type_stays_silent: the zero written as int, long, uint, ulong, byte, short and char, innew,stackalloc,GC.AllocateArrayandArray.Resize;[1L]andstackalloc [(byte)1]reported. Seeding the int-only match back fails it: 8 reports where 2 are expected.tools/BuildVerdict.🤖 Generated with Claude Code