Open salgiza opened 4 years ago
I wonder though if this is because implicit conversions are currently only deprecated, not disallowed.
Hi! As things stand right now, you would get an ambiguous overload in certain cases. Whenever using overloads, keep in mind that the conversion matrix for AL contains a lot of tricky cases for backwards compatibility which might lead to unexpected behavior.
Encoutered the same when refactoring some of our functions from options to enums (as a reference https://www.yammer.com/dynamicsnavdev/#/threads/show?threadId=1156165716639744).
AL Compiler must include a CodeCop to at least alert or auto-resolve conversions, since now we unintentionally introduce new breaking changes for all dependent extensions. With the introduction of the new overload functions, extensions fail to compile and get warning below
The call is ambiguous between the method 'xxx(Option)' and the method 'xxx(Enum "My Enum")'
For my extension I had an even more annoying problem. I'm able to compile the package in VS Code and I'm getting no error. But as soon as i try to publish the extension I receive this error. That's why i think that this issue should being marked as bug and not only as enhancement.
The call is ambiguous between the method ....
Describe the bug You can't declare these two methods in the same codeunit:
procedure MyMethod(X: Integer); procedure MyMethod(X: Enum MyEnum);
Or even these two methods: procedure MyMethod(X: Option); procedure MyMethod(X: Enum MyEnum);
Note: if you are wondering, I was migrating an app that has been upgraded from using options to enums. Having both methods was intended to keep compatibility with previous customers.
To Reproduce Just declare two procedures with the same name in a Codeunit, one with a single Integer param and the other with a single Enum param. The AL compiler thinks that both procedures are the same.
Expected behavior The AL compiler should have detected a different signature and use the Enum method if called with an Enum of that Type, and the Integer procedure otherwise.
Screenshots
5. Versions: