microsoft / microsoft/AL

Error AL0133 when using Variant by reference as parameter of function and passing record

Open
#5,030 14 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PowerShell
Stars
881
Forks
285
Avg merge
3d 36m
Merged PRs (30d)
1

Description

In AL, when I define function with parameter of type variant passed by reference, I cannot call the function by passing record, because I will get error:

Argument 2: cannot convert from 'Record "tablename"' to 'var Variant'

This prevents me to do generic functions consuming any record and returning the modified record back. It was possible to use var Variant parameter in C/Side and pass record.

Create e.g. function like this:
image

Try to call it with two records. You will get the error in "PROBLEMS" section of the VSCode.

Workaround:
Use variant variable, assign the record, use the variant variable as parameter, assign the variable back to the record after the call. But why should I do this?

AL Language: 3.0.124247

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the function call described in the issue by passing two records to a by-reference Variant parameter and inspect the diagnostic in VS Code's PROBLEMS section. Investigate the AL compiler's argument-conversion handling for records and var Variant parameters; done means the call is accepted without AL0133 and the modified record is returned as described.

Written by the indexing model from the issue text.

Assessment

Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.