If a system overload is not available in the used runtime, why AL0196 "call is ambiguous"?
1. Describe the bug In existing code, we use variant types. However, the new overloads for fully qualified object names in RecordRef.Open(), Page.Run(), Report.Run(), Codeunit.Run() showing errors when used with a variant.
This is a behavior change and will for sure break the installation on BC28 for unchanged apps. At least the developer experience is reduced.
If a system overload is not available in the used runtime, why AL0196 "call is ambiguous"? If my runtime does not support >1 method signature, is can never be ambiguous.
2. To Reproduce Use one of the following code lines. The comments show the problems raised in the line before.
recRef.Open('Item');
// 'Open' is not available in runtime version '14.0'. The supported runtime versions are: '17.0' or greater.
recRef.Open(forVariant);
// The call is ambiguous between the method 'Open(Integer, [Boolean], [Text])' defined in Class 'RecordRef' by the extension '' and the method 'Open(Text, [Boolean], [Text])' defined in Class 'RecordRef' by the extension ''.
Codeunit.Run('Namespace.Name');
// 'Run' is not available in runtime version '14.0'. The supported runtime versions are: '17.0' or greater.
Codeunit.Run(forVariant);
// The call is ambiguous between the method 'Run(Integer, var [Table])' defined in Class 'Codeunit' by the extension '' and the method 'Run(Text, var [Table])' defined in Class 'Codeunit' by the extension ''.
Page.Run('Namespace.Name');
// 'Run' is not available in runtime version '14.0'. The supported runtime versions are: '17.0' or greater.
Page.Run(forVariant);
// The call is ambiguous between the method 'Run(Integer, [Table], [Joker])' defined in Class 'Page' by the extension '' and the method 'Run(Text, [Table], [Joker])' defined in Class 'Page' by the extension ''.
Codeunit.Report('Namespace.Name');
// 'Run' is not available in runtime version '14.0'. The supported runtime versions are: '17.0' or greater.
Codeunit.Report(forVariant);
// The call is ambiguous between the method 'Run(Integer, [Boolean], [Boolean], var [Table])' defined in Class 'Report' by the extension '' and the method 'Run(Text, [Boolean], [Boolean], var [Table])' defined in Class 'Report' by the extension ''.
3. Expected behavior I understand that the new overloads, which are great, having issues with a variant when two overloads exist. And I understand that it is complicated to identify the wrapped datatype compile time.
But I expect the compiler to respect my configured runtime. As long as my runtime does not support these overloads, I do not like to have my code broken. I would expect a warning in runtimes < 17.0 and these actual errors when using runtime 17.0+.
4. Actual behavior See the comments in 2.
5. Versions:
- AL Language: 17.0.1869541
- Visual Studio Code: 1.105.1
- Business Central: OmPrem-de-26.5
- Operating System:
- [x] Windows
- [ ] Linux
- [ ] MacOS
Internal work item: AB#612436
And let me add: It breaks pipelines on NextMajor, when dependencies or any app to publish have a construct like this.
The same situation (but more details) with this code (where parameter is Variant, but it is tested to Integer type):
procedure GetRecordRef(TableId: Variant; var RecRef: RecordRef): Boolean;
begin
case true of
...
TableId.IsInteger():
RecRef.Open(TableId);
...
end;
end;