Skip to content

Poor error recovery when declaring a pointer to an array type #33482

@YairHalberstadt

Description

@YairHalberstadt

Version Used: master

Steps to Reproduce:

using System.Collections.Generic;

class C
{
    unsafe void M1()
    {
        int[] *y;
        List<int> *z;
    }
}

https://sharplab.io/#v2:EYLgtghgzgLgpgJwDQxASwDYB8ACAGAAhwEYAWAbgFgAoGnAJgIGEaBvGgzggVwDsoIAMzhFSBALLEAFAEoOXdtS7KCaXjADaAXQIAqAJ5UlKzgBk0sADxqYAPj0AvI8oC+NF0A=

Expected Behavior:

Following errors are produced:

error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('int[]')

error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('List')

Actual Behavior:

Following errors are produced:

error CS1001: Identifier expected
error CS1002: ; expected
error CS0103: The name 'y' does not exist in the current context
error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('List')

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions