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

Closed
1 of 4 tasks
thechriskent opened this issue Apr 3, 2019 · 6 comments
Closed
1 of 4 tasks

Subtraction Operations Incorrectly Tokenized in List Formatting #3733

thechriskent opened this issue Apr 3, 2019 · 6 comments

Comments

@thechriskent
Copy link
Task lists! Give feedback
Collaborator

@thechriskent thechriskent 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
Copy link
Collaborator

@msft-github-bot msft-github-bot commented Apr 3, 2019

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

@andrewconnell
Copy link
Collaborator

@andrewconnell andrewconnell commented Apr 4, 2019

@thechriskent
Copy link
Collaborator Author

@thechriskent thechriskent commented Apr 4, 2019

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

@andrewconnell
Copy link
Collaborator

@andrewconnell andrewconnell 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? :)

@shagra-ms
Copy link
Contributor

@shagra-ms shagra-ms commented Jan 27, 2020

This was fixed in May 2019.

@thechriskent Are you still facing this issue?

@shagra-ms shagra-ms closed this Jan 27, 2020
@msft-github-bot
Copy link
Collaborator

@msft-github-bot msft-github-bot commented Feb 4, 2020

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

@SharePoint SharePoint locked as resolved and limited conversation to collaborators Feb 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants