Skip to content

CMTK0005 reports a multidimensional array with a zero dimension, such as new Plain[0, 2], which holds no element #227

Closed

Description

@CaffeinatedCoder

Reported by an external review of release/2.3.1 @ dbdd44e, which reproduced it; the cause confirmed here by reading the source, not yet run.

Package

CodoMetis.TypeKit.Analyzers

Version

2.3.0 (the same code in v2.3.0), and release/2.3.1 @ dbdd44e

How does it fail?

Loudly. A warning on an array that holds no element

Problem

DefaultFilledCollectionAnalyzer.AnalyzeArrayCreation (src/CodoMetis.TypeKit.Analyzers/DefaultFilledCollectionAnalyzer.cs:69) skips an empty array only when every dimension is a constant 0 (All). A multidimensional array is empty when any dimension is 0, so new Plain[0, 2] holds no default value object and is reported.

Scenario

var none = new Plain[0, 2];   // CMTK0005; expected: nothing, it has no elements
var also = new Plain[2, 0];   // the same
var some = new Plain[2, 2];   // CMTK0005, rightly

stackalloc (:110) has one dimension, where All and Any agree.

Change

Any in place of All at :69. A Warning reporting less needs no exception to decision 34.

Test

CMTK0005 rows for [0, 2], [2, 0], [0, 0], a jagged [0][] and [2, 2], the last reported; reverted per verify-the-guard. Input class: an array creation of a value object, by rank and which dimension is a constant zero.

Environment

.NET SDK 10.0.4xx; any consumer.

Activity

  1. added this to the 2.3.1 milestone on Oct 31, 2026
  2. added
    bugSomething isn't working
    severity/lowCosmetic, message or documentation-level difference
    package/analyzersAffects CodoMetis.TypeKit.Analyzers
    area/value-objectsValue-object contracts and what the aspects generate for them
    on Oct 31, 2026
  3. CaffeinatedCoder commented on Oct 31, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Fixed in #233. Running the input class across how the zero is written found a sibling, fixed in its own commit there (Found-By: VA): the zero check matched only a boxed int, so new Plain[0L], [0u, 2], [2, 0ul] and stackalloc Plain[(byte)0], [(short)0], ['\0'] were reported too. One IsZero now reads every integral constant.

  4. CaffeinatedCoder commented on Oct 31, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Fixed by #233, merged into release/2.3.1 (2e60d4c); ships in 2.3.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/value-objectsValue-object contracts and what the aspects generate for thembugSomething isn't workingpackage/analyzersAffects CodoMetis.TypeKit.Analyzersseverity/lowCosmetic, message or documentation-level difference

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions