microsoft / microsoft/AL

Negative sign change on Duration Datatype

Open
#5,137 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

You cannot change sign to negative for Duration datatype. Error is: Operator '-' is ambiguous on an operand of type 'Duration'.

Sample of Code that gives an error:
if ShortenMaxDuration then MaxDuration := -EscalationDuration else MaxDuration := EscalationDuration;

Expected behavior
I expect that MaxDuration gets negative value (as any numeric value).
MaxDuration = 0
EscalationDuration = 1000;
MaxDuration = -EscalationDuration
should give:
MaxDuration = -1000;

Versions:
AL Extension Version: 3.0.106655

  • Business Central: 14.0.29530.0

Thanks,
Zoran

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

Start with the Duration unary-minus example in the issue and reproduce the ambiguous '-' diagnostic using the listed AL Extension and Business Central versions. Trace the compiler handling for Duration operands and verify completion when assigning -EscalationDuration to MaxDuration produces the expected negative value without an ambiguity error.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.