Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subtraction Operations Incorrectly Tokenized in List Formatting #3733

Open
thechriskent opened this Issue Apr 3, 2019 · 4 comments

Comments

Projects
None yet
3 participants
@thechriskent
Copy link
Member

commented Apr 3, 2019

Category

  • Question
  • Typo
  • Bug
  • Additional article idea

Expected or Desired Behavior

A list formatting expression using a subtraction operator should work with both simple numbers and nested operations.

Observed Behavior

The subtraction operator is recognized as a negative modifier for a number rather than as a subtraction operator when the first operand is a nested operation. This leads to expressions being returned as strings rather than being correctly evaluated. The issue is within the AST Tokenizer.

Steps to Reproduce

Using this format we see the expected result:

{
  "elmType": "div",
  "txtContent": "=4-2"
}

Here is how the tokenizer recognizes this expression:
image

All values are returned as 2 as expected.


Applying the following derivation we run into problems (applied to a multi-choice column):

{
  "elmType": "div",
  "txtContent": "=length(@currentField)-2"
}

Here is how the tokenizer recognizes this expression:
image

Notice that the - and the 2 have been incorrectly combined into -2. This causes the operation/operand evaluation to fail since this isn't a valid expression. This results in the expression being returned as a string rather than the evaluation of the expression:

image

Note that adding spaces makes no difference.


The addition operator does not have this problem:

{
  "elmType": "div",
  "txtContent": "=length(@currentField)+2"
}

Correct tokenization:
image


It is possible to work around this problem by surrounding raw numbers used in the right-side of the subtraction operation in parenthesis:

{
  "elmType": "div",
  "txtContent": "=length(@currentField)-(2)"
}

image

This is a temporary solution and definitely not an obvious one.

@msft-github-bot

This comment has been minimized.

Copy link
Collaborator

commented Apr 3, 2019

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@andrewconnell

This comment has been minimized.

Copy link
Collaborator

commented Apr 4, 2019

@thechriskent

This comment has been minimized.

Copy link
Member Author

commented Apr 4, 2019

@andrewconnell Did you just tag me in my own issue? 😆

@andrewconnell

This comment has been minimized.

Copy link
Collaborator

commented Apr 4, 2019

Oops... me thinks I maybe was triaging too quickly this morning...


Parker hides...

With that being said... any ideas on your own issue? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.