Skip to content

Fix CGS020 false positive for typed array properties ("Array of X") - #151

Merged
davhdavh merged 2 commits into
mainfrom
copilot/fix-wrong-parse-of-array
Jul 3, 2026
Merged

Fix CGS020 false positive for typed array properties ("Array of X")#151
davhdavh merged 2 commits into
mainfrom
copilot/fix-wrong-parse-of-array

Conversation

Copilot AI commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Assigning a class property that returns a typed array (e.g. AppProduct.Roles) to an array-typed variable incorrectly raised CGS020: Invalid data type 'Array of AppProductRole', expect 'array'.

AppProduct app = AppProduct_getById(appProductId);
array roles = app.Roles;   // previously: CGS020 false positive

Root cause

  • Runtime metadata reports element-typed array properties generically as "Array of <ElementType>".
  • SemanticAnalyzer.MapToCanonical only recognized a fixed set of these strings ("Array of objects", "Array of ints", "Array of strings"); any other element type name fell through unmapped and was compared as if it were an unrelated class type.

Fix

  • MapToCanonical now maps any string with the "Array of " prefix to the canonical "Array" type, instead of relying on an enumerated allow-list.

Tests

  • Added a regression test covering a property typed as "Array of AppProductRole" assigned to an array variable, verifying no CGS020 diagnostic is produced.

Copilot AI linked an issue Jul 3, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix wrong parse of array leading to type error Fix CGS020 false positive for typed array properties ("Array of X") Jul 3, 2026
Copilot AI requested a review from davhdavh July 3, 2026 08:07
@davhdavh
davhdavh marked this pull request as ready for review July 3, 2026 08:08
@davhdavh
davhdavh merged commit 7da44cf into main Jul 3, 2026
@davhdavh
davhdavh deleted the copilot/fix-wrong-parse-of-array branch July 3, 2026 08:08
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 2.32.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wrong parse of array

2 participants