microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
719 stars 242 forks source link

Enum Ordinals Reverse is not a supported operation #7703

Closed DominicSaladin closed 2 months ago

DominicSaladin commented 3 months ago

1. Describe the bug When using Reverse on the List of [Integer] returned by Enum::"My Enum".Ordinals(); the Compiler allows the package building, but BC throws the error The requested operation is not supported.. Is the Ordinals List read-only and if yes, why? For me, it seems like a bug.

2. To Reproduce

var
    MyList: List of [Integer];

MyList := Enum::"My Enum".Ordinals();
MyList.Reverse();

3. Expected behavior The list gets reversed

4. Actual behavior On runtime the error The requested operation is not supported. gets thrown, but the compiler does not detect this error on compilation

5. Versions:

BazookaMusic commented 3 months ago

This one is interesting. The reason why it's read-only today is because the implementation returns the same instance for all calls to this method. Performance wise this is more efficient as it avoids creating multiple copies of the ordinal values.

I see no mention of the fact that it is read-only in our docs however, so we at the very least have a doc defect.

I'm marking it for triage, so the team can examine two things: 1) Should the docs be updated? 2) Should the GetOrdinals() and the GetNames() functions be read-only since this concept does not exist in AL?

thloke commented 2 months ago

Hi, this issue is out of scope of for this repository. You should do one of the following:

As a reminder, this repository only handles issues to do with the compiler or VSCode development experience for AL.

The reason why this is out of scope is because this is a runtime limitation. As far as the compiler is concerned, it's a list of integers and so it's treated as such. We don't have a readonly concept as mentioned - though such a concept would be beneficial here since then the compiler could actually raise a warning/error in this case. I'm not sure where else we might have readonly data, but if we run into this problem frequently we can consider introducing the concept.