Can't return variant when using an interface
1. Describe the bug You can return a variant (as return type of a procedure) when you use the procedure directly. However, when you call the same procedure using an interface you get an exception:
The user-defined C/AL function 'Bla' requires 2 parameters. It was called with 2 parameters.
Where the 2 in the above exception is the number of 'normal' parameters the function has. Ie. procedure GetSomething(foo: Text; bar: Text) : Variant
2. To Reproduce Steps to reproduce the behavior:
Create an interface with a single procedure that returns a Variant. Create a codeunit that implements this interface. Try to call the function using the interface.
interface IVariantException
{
procedure Foo(foo: Text; bar: Text): Variant
}
codeunit 50000 VariantException implements IVariantException
{
procedure Foo(foo: Text; bar: Text): Variant
begin
end;
}
codeunit 50001 TestVariantException
{
Trigger OnRun()
var
TestInterface: Interface IVariantException;
TestCodeunit: Codeunit VariantException;
begin
TestInterface := TestCodeunit;
TestInterface.Foo('foo', 'bar');
end;
}
3. Expected behavior Code runs and can return a variant without throwing an exception.
4. Actual behavior Throws an exception.
5. Versions:
- AL Language: 7.2.475273
- Visual Studio Code: 1.56.2
- Business Central: 18.1.24822.25949
sounds similar to #6647
Closing as duplicate