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
728 stars 241 forks source link

Implicit conversion is being performed from Enum to Option #7613

Closed Daniamstutz closed 7 months ago

Daniamstutz commented 8 months ago

Description I create a new FlowField and link it via the Source Subtype, this is once Option and the other time Enum.

Therefore I get the following warning:

An implicit conversion is being performed from a value of type 'Enum "Sales Document Type"' to a value of type 'Option'. This conversion can lead to unexpected runtime issues. This warning will become an error in a future release.

image

How can I work around this?

Repo

tableextension 99999 "Sales Line Extension" extends "Sales Line"
{
    fields
    {
        field(99999; "Assigned Bin Reserv."; Integer)
        {
            CalcFormula = count("Reservation Entry" where("Reservation Status" = const("BOSS Bin Reservation"),
                                                           "Source Type" = const(37),
                                                           "Source Subtype" = field("Document Type"),
                                                           "Source ID" = field("Document No."),
                                                           "Source Ref. No." = field("Line No.")));
            Caption = 'Assigned Bin Reserv.';
            Editable = false;
            FieldClass = FlowField;
        }
    }
}
dannoe commented 8 months ago

see https://github.com/microsoft/ALAppExtensions/issues/14372#issuecomment-921926396 more references: https://github.com/microsoft/AL/issues/6784

BazookaMusic commented 8 months ago

I think we should look at this warning error. If there is no workaround and people have to use pragmas to resolve it, then we cannot force it to be an error. We should look at how this can be handled

qutreson commented 7 months ago

We have discussed this internally and we are currently not planning to turn this into an error, so we will remove the part of the message mentioning a future change of severity. For cases such as the one you mentioned above, you can then use a pragma directive to suppress it. Note that the diagnostic remains valid since this type of conversion can cause issues and fixing it, when possible, remains the recommended approach.

JesperSchulz commented 7 months ago

The fix for this issue has been checked in to the master branch. It will be available in the bcinsider.azurecr.io/bcsandbox-master Docker image starting from platform build number 24.0.15509.0 and VS Code Extension Version 13.0.929061.

If you don’t have access to these images you need to become part of the Ready2Go program: aka.ms/readytogo

For more details on code branches and docker images please read: https://blogs.msdn.microsoft.com/nav/2018/05/03/al-developer-previews-multiple-releases-and-github/ https://freddysblog.com/2020/06/25/working-with-artifacts/