AL
AL copied to clipboard
Missing parenthesis in Enum methods throws error in platform but not in compilation time
1. Describe the bug Missing parenthesis in Enum methods throws error in platform but not in compilation time.
2. To Reproduce Steps to reproduce the behavior:
- Create an Enum
enum 70021 "ABC Sale Type"
{
value(0; A) {}
value(1; B) {}
}
- Add this code
Txt := Enum::"ABC Sale Type".Names.Get(Enum::"ABC Sale Type".Ordinals.IndexOf(1))
3. Expected behavior AL compiler should throw a clear error because error is thrown later in platform.
4. Actual behavior You can compile but an error is thrown when you try to publish: Unexpected value 'NoConversion' of type 'Microsoft.Dynamics.Nav.CodeAnalysis.ConversionKind') Unexpected value 'NoConversion' of type 'Microsoft.Dynamics.Nav.CodeAnalysis.ConversionKind'
5. Solution: Add parenthesis to Names() method and Ordinals() methods
Txt := Enum::"ABC Sale Type".Names().Get(Enum::"ABC Sale Type".Ordinals().IndexOf(1))
6. Versions:
- AL Language: I guess 12.1
- Visual Studio Code: 1.85.1
- Business Central: 23.1
Final Checklist
Please remember to do the following:
- [X] Search the issue repository to ensure you are reporting a new issue
- [X] Reproduce the issue after disabling all extensions except the AL Language extension
- [X] Simplify your code around the issue to better isolate the problem
Thank you for the repro, it's super useful. Happy new year!
Duplicate/related to #7477 ?