Al: 'TestField' is not available in runtime version '5.0' since ALC update

Created on 23 May 2020  Â·  16Comments  Â·  Source: microsoft/AL

Describe the bug
Since latest update to 5.0.277602 the packages fails to build with the following errors:

error AL0666: 'TestField' is not available in runtime version '5.0'. The supported runtime versions are: '5.2' or greater.

error AL0666: 'Enum to generic enum conversion' is not available in runtime version '5.0'. The supported runtime versions are: '5.2' or greater.

This error is only with TestField on Enums as it seems. Before the update the package could be compiled without errors.

To Reproduce
Steps and to reproduce the behavior:

  1. Create a project with runtime 5.0
  2. Create a Codeunit file
  3. Insert code:

local procedure ReproduceError ()
var
PurchaseHeader: Record "Purchase Header";
begin
PurchaseHeader.TestField(Status, PurchaseHeader.Status::Open);
end;

Expected behavior
The project should compile without error as before the update.

5. Versions:

  • AL Language: 5.0.277602
  • Business Central: 16.0.11310.0
bug in-progress

Most helpful comment

@jwikman That's why vscode has the facility to switch to previous versions easily. The developers (of vscode) know it's a problem to revoke an upload to the "Marketplace" and don't trust extension developers to upload working extensions.

Also even though this message has no impact on the compiler's ability to generate C# code it cannot be suppressed with ruleset.json so skipping the version is your only option.

All 16 comments

Thanks for reporting this issue! It looks like the attempt to silence some of the conversion warnings around enums backfired.

@atoader is it safe to ignore this then?
Ie. stay on previous release of compiler until this is solved...

@jwikman That's why vscode has the facility to switch to previous versions easily. The developers (of vscode) know it's a problem to revoke an upload to the "Marketplace" and don't trust extension developers to upload working extensions.

Also even though this message has no impact on the compiler's ability to generate C# code it cannot be suppressed with ruleset.json so skipping the version is your only option.

@jwikman it is safe to ignore it. I published a new extension to the marketplace that fixes the issue. Can you try it out?

@atoader sure, just let me know when to try. I've got plenty of repro code :-)

It should be available right now. The version is 5.0.279165

Installing...

@atoader I can confirm that the new version fixes this issue.

No more AL0666 errors!
And no more AL0603, as this probably was what you where trying to fix in the first place. :)

Thanks for fast action on this!

Ohh. AL0603 also fixed. Thanks!

Hmm. AL0603 is still giving errors when trying to assign an enum to an integer variable.

I have this code:

SourceDocType := TempConsHead."Source Document Type"; with FreightPayerRule do begin SetFilter("Source Document Type", '%1|%2', "Source Document Type"::" ", SourceDocType);

FreightPayerRule."Source Document Type" is of another enum type than TempConsHead."Source Document Type". I would really like to do like this:

SetFilter("Source Document Type", '%1|%2', "Source Document Type"::" ", TempConsHead."Source Document Type");

But that gives me a compile error (AL0193). To work around that I assign the enum to an integer, but AL0603 complaines about that.

So AL603 goes back into my ruleset and I'll have to keep this conversion over the integer variable.

@larswestman have you seen the FromInteger(..) function on the Enum type and the AsInteger() function on the Enum variable?

I think they should solve your problem.

Declare your SourceDocType variable as the same Enum as on FreightPayerRule (I call it MyEnum in below sample).
Then you do this:

SourceDocType := MyEnum.FromInteger(TempConsHead."Source Document Type".AsInteger());
SetFilter("Source Document Type", '%1|%2', "Source Document Type"::" ", SourceDocType);

All this, obviously, assumes that the integer values for the two enums are corresponding to eachother....

Thanks @jwikman
This is even simpler: SetFilter("Source Document Type", '%1|%2', TempConsHead."Source Document Type".AsInteger(), "Source Document Type"::" ");

Somehow I have the feeling that the number, 666, was deliberately chosen to annoy us ;)

Not only you, @MODUSCarstenScholling ;-)

@MODUSCarstenScholling :laughing:
Nope sorry, it was specifically chosen because it's a because the error would never be seen. Remember, that number is often on the bad word list, right with "F*" and "Jes".

Error('This cannot happen');

Thanks for confirming it works :)! I'll close this issue.

Was this page helpful?
0 / 5 - 0 ratings