Closed rdebath closed 4 years ago
Hi @rdebath,
With the following code I'm able to get the "Unused variables" warning, however I can't get the stack trace to show. Could you provide a some code that reproduces that issue.
page 50100 PageOne
{
ApplicationArea = Basic, Suite;
UsageCategory = Administration;
layout
{
area(Content)
{
group(GroupName)
{
field(TextField; 'SomeField')
{
ApplicationArea = Basic, Suite;
CaptionClass = Format(StrSubstNo(NormalText, Format(WorkDate)));
}
field(LabelField; 'SomeField')
{
ApplicationArea = Basic, Suite;
CaptionClass = Format(StrSubstNo(LabelTxt, Format(WorkDate)));
}
field(TextConstField; 'SomeField')
{
ApplicationArea = Basic, Suite;
CaptionClass = Format(StrSubstNo(TextConstTxt, Format(WorkDate)));
}
field(Text000Field; 'SomeField')
{
ApplicationArea = Basic, Suite;
CaptionClass = Format(StrSubstNo(Text000, Format(WorkDate)));
}
}
}
}
var
NormalText: Text;
LabelTxt: Label 'My # Label';
TextConstTxt: TextConst JPN = 'My # Label';
Text000: Label 'My # Label'; // From comment below: Comment this variable out to reproduce the crash.
WorkDate: Date;
}
After deleting almost everything from the project with the problem I finally realised where the weird "protection level" error was coming from. It appears that the MS/AL compiler thinks that globals in the SourceTable
of a page are in some way accessible to the page sometimes. So if you add
SourceTable = Customer;
to the page you'll get the crash with Text000
.
I just tried adding the SourceTable = Customer;
to the code and noticed that Text000
is a global variable of type Label defined on the customer table, so that is inaccessible by design, but it doesn't crash for me.
Are you using the latest version from the marketplace?
Yup, I'm still on the same version of the AL extension. The crash doesn't seem to depend on the version of the symbols (below is V13, previous are on V15 and runtime 4.0).
I've disabled all other extensions in this workspace; no change. The version of vscode was updated; no change.
When I comment out and save your altest.al
the "protection level" error and the exception against app.json
both appear at the same time.
Name: AL Language
Id: ms-dynamics-smb.al
Description: AL development tools for Dynamics 365 Business Central
Version: 4.0.182565
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-dynamics-smb.al
{
"id": "1fdb0e4e-82b1-4605-b4ff-86be4fe05b9c",
"name": "ZZZ Hello World",
"publisher": "TVision (Temp)",
"version": "2.0.0.0",
"features": [
"TranslationFile"
],
"idRanges": [{ "from": 50000, "to": 99900}],
"application": "13.0.0.0",
"platform": "13.0.0.0",
"runtime": "3.0"
}
{
"al.enableCodeAnalysis": true,
"al.codeAnalyzers": [
"${CodeCop}"
]
}
{
"version": "0.2.0",
"configurations": [
{
"type": "al",
"name": "BC on Navdev",
"authentication": "Windows",
"server": "http://navdev.tvt.local",
"serverInstance": "BC130",
"port": 7049,
"request": "launch",
"startupObjectType": "Page",
"startupObjectId": 2500,
"schemaUpdateMode": "ForceSync"
}
]
}
I got it now. I forgot to comment out the declaration in the current object. Thanks for reporting the bug.
We were not able to reproduce this issue on the latest insider build. Could you verify and reopen the issue if it still occurs?
Describe the bug Warning [AA0137] is emitted for a variable that is being used.
To Reproduce
Then define the variable as a text constant. In addition different errors are produced if the variable's name is
Text000
. A message that the variable is inaccessible due to it's protection level and a crash registered againstapp.json
. This is in a page, not a page extension.Expected behavior Text constant is being used so warning isn't correct.
Screenshots
5. Versions: Name: AL Language Id: ms-dynamics-smb.al Description: AL development tools for Dynamics 365 Business Central Version: 4.0.182565 Publisher: Microsoft VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-dynamics-smb.al