Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
1. Describe the bug
A return parameter of type JsonObject will be return as uninitialized if not explicitly set.
In BC versions up to 18 you could instantiate a return parameter of any type in a procedure and
the return value was valid, even if not explicitly assigned. (see code below)
2. To Reproduce
Take the function described below and check the return value.
In BC 19 the return value is uninitialized.
procedure newJson() newObj: JsonObject
begin
end;
In versions up to BC version 18 this is a legal function, because newObj is instantiated as a local variable and contains a valid empty JSON object. This valid object will be given back to the caller. There is no need to make any assignment to jobj in the procedure body.
jsonvar := newJson() ; // will always initialize jsonvar with a new empty JsonObject
jsonvar.Add('Testproperty', 42); // should work
3. Expected behavior
I would expect to have an empty JsonObject in jsonvar after the call.
4. Actual behavior
After the call
jsonvar := newJson() ;
the debugger shows the content of jsonvar as "uninitialized"
and
jsonvar.Add('Testproperty', 42); // rises a runtime error
5. Versions:
AL Language: 8.1.525271
Visual Studio Code: 1.54.3
Business Central: Version: W1 19.0 (Platform 19.0.29884.30666 + Application 19.0.29894.30693)
This version and below does not have this error:
Version: W1 18.0 (Platform 18.0.22893.23773 + Application 18.0.23013.23795)
1. Describe the bug A return parameter of type JsonObject will be return as uninitialized if not explicitly set.
In BC versions up to 18 you could instantiate a return parameter of any type in a procedure and the return value was valid, even if not explicitly assigned. (see code below)
2. To Reproduce
Take the function described below and check the return value. In BC 19 the return value is uninitialized.
procedure newJson() newObj: JsonObject begin end;
In versions up to BC version 18 this is a legal function, because newObj is instantiated as a local variable and contains a valid empty JSON object. This valid object will be given back to the caller. There is no need to make any assignment to jobj in the procedure body.
jsonvar := newJson() ; // will always initialize jsonvar with a new empty JsonObject jsonvar.Add('Testproperty', 42); // should work
3. Expected behavior
I would expect to have an empty JsonObject in jsonvar after the call.
4. Actual behavior
After the call jsonvar := newJson() ;
the debugger shows the content of jsonvar as "uninitialized" and jsonvar.Add('Testproperty', 42); // rises a runtime error
5. Versions:
This version and below does not have this error: Version: W1 18.0 (Platform 18.0.22893.23773 + Application 18.0.23013.23795)
Final Checklist