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

Missing warning/error to prevent the "The table IDs do not match." run-time error #7600

Closed NKarolak closed 9 months ago

NKarolak commented 9 months ago

1. Describe the bug A compiler warning (and later error) is missing to prevent the following run-time error:

The table IDs do not match.

2. To Reproduce Declare the following code:

    procedure TestRunPage()
    var
        PurchaseHeader: Record "Purchase Header";
    begin
        Page.Run(Page::"Sales Order", PurchaseHeader)
    end;

Run the procedure in the client. An error will occur.

3. Expected behavior Prior to publishing the code, the compiler should warn that the SourceTable of page "Sales Order" does not match the record variable passed in Page.Run or Page.RunModal. In later versions, the AL warning should be turned into an error.

4. Actual behavior No warning or error on compiling.

5. Versions:

BazookaMusic commented 9 months ago

This would be a good codecop rule, but not a compiler rule by itself. It stems from the fact that AL lacks generics and thus the page type does not encapsulate its expected record type. Unfortunately, this makes the example provided valid AL code.

There's quite a few methods that have this issue due to the same reason: eg. page.SetRecord()

I would suggest to report this in aka.ms/bcideas instead. We use the amount of votes as a way to prioritize ideas.

NKarolak commented 9 months ago

https://experience.dynamics.com/ideas/idea/?ideaid=73ba02e7-f98d-ee11-a81c-000d3a7a4389