Open bjarkihall opened 1 year ago
We found a related bug today:
foreach o in Enum::"Client Type".Ordinals do
Message(Format(o));
This compiles fine, but throws a nasty bug on publish/install (I hope this comment helps someone, since there's nothing helpful in the message about where said bad expression is):
Failure while emitting method. Object:'Codeunit "MyCodeunit"' Method:'MyMethod()' (Unexpected value
'BadExpression' of type 'Microsoft.Dynamics.Nav.CodeAnalysis.BoundKind')
Unexpected value 'BadExpression' of type 'Microsoft.Dynamics.Nav.CodeAnalysis.BoundKind'.
Fixed by changing it to:
foreach o in Enum::"Client Type".Ordinals() do
Message(Format(o));
I see the Ordinals issue had been discovered already and reported in #7525 (I'm adding this comment here so we have a link between them). I noticed it has should be fixed according to changelog in: https://marketplace.visualstudio.com/items/ms-dynamics-smb.al/changelog#user-content-github-issues
Please include the following with each issue:
1. Describe the bug This bug has been discussed to some degree in a yammer thread (https://www.yammer.com/dynamicsnavdev/#/Threads/show?threadId=2331527012761600) but this ticket is created for easier tracking/discovery and discussion.
Basically, Enum.AsInteger lose semantic highlighting and hover won't give you a tooltip if the parenthesis are missing. Method chains still work without any parenthesis needed, if that information helps. I noticed another case where indexing an array with an Enum would cause a warning (previously I think it was an error but it raises an AL0603 warning now). It might be related to AL Namespaces?
I have AL Language version (v12.0.842197), the runtime is 11 though, if that makes a difference. Just let me know if I can help any further, and thanks for looking into this.
2. To Reproduce Here I've tried some of the different scenarios that came to mind:
Passing them as parameters also causes the warning, not just using them as array indexes:
Also, since it doesn't know that AsInteger has changed it from EnumValue to Integer, it raises a warning when you try to assign it to an Integer variable:
Also note that using these as return values reverses the issue:
3. Expected behavior I expect AsInteger and AsInteger() to work the same. This is just a simple case but there might be a related use-case / pattern which might also silently break once we upgrade to v12.
4. Actual behavior Here are the current results:
Note that playing around with these also made the formatter go rogue like adding linebreaks to 3439, but reloading vscode seemed to fix it, this kind of stuff might be expected when the intention is to break the lexer, so it might not be relevant but I decided to include it here if it's relevant:
5. Versions:
Final Checklist
Please remember to do the following:
[x] Search the issue repository to ensure you are reporting a new issue
[x] Reproduce the issue after disabling all extensions except the AL Language extension
[x] Simplify your code around the issue to better isolate the problem