Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 19, 2025

The grammar only matched single * for pointer types. Multi-level pointers (int**, int***) beyond the first level were incorrectly tokenized as arithmetic operators instead of type punctuation.

Changes

  • array-creation-expression: Changed pointer suffix from (?:\s*\?\s*)? to (?:\s*\*\s*)* followed by (?:\s*\?\s*)? to support multiple pointer levels before nullable suffix
  • local-variable-declaration: Changed (?:\s*[?*]\s*)? to separate pointer pattern (?:\s*\*\s*)* and nullable pattern (?:\s*\?\s*)?

Example

unsafe
{
    int* p = stackalloc int[10];      // Already worked
    int** pp = stackalloc int*[10];   // Now tokenizes all * correctly  
    int*** ppp = stackalloc int**[10]; // Now tokenizes all * correctly
}

All pointer asterisks now consistently receive punctuation.separator.asterisk.cs scope.

Original prompt

This section details on the original issue you should resolve

<issue_title>stackalloc for pointer array declaration</issue_title>
<issue_description>## Details

What editor are you seeing the problem in? (e.g. Atom, Visual Studio Code, etc.)
vscode
What version of the editor are you using?
1.88.1
What color theme are you using?
dark plus

Repro

unsafe
{
    int* p = stackalloc int[10];
    int** pp = stackalloc int*[10];
    int*** ppp = stackalloc int**[10];
    int**** pppp = stackalloc int***[10];
}

image

Please provide a code example and (optionally) a screenshot demonstrating the problem.</issue_description>

<agent_instructions>From the example, it appears that pointer only support one level of indirection and additional * are not being classified properly.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix stackalloc for multi-level pointer array declaration Fix multi-level pointer type tokenization in stackalloc and variable declarations Dec 20, 2025
Copilot AI requested a review from JoeRobich December 20, 2025 00:26
@JoeRobich JoeRobich requested a review from dibarbet December 20, 2025 01:33
@JoeRobich JoeRobich marked this pull request as ready for review December 20, 2025 02:12
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.

stackalloc for pointer array declaration

2 participants