fix missing wrapping in t_handler() #110
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a proposition to fix #108.
The fix proposed in #109 corrects the issue in most cases without properly identifying the cause, which might cause other issues.
The issue
When we deal with concatenation expressions in
evaluate_parse_tree()
, the retrieved value is always unwrapped (for example at lines 2274 and 2276).However in
t_handler()
, the returnedEvalResult
does not wrap the value.This is ok when the value does not start and end with quotes (this is the majority of cases), since
unwrap_str_literal()
does nothing if the string to unwrap does not start and end with quotes.But if the result of
t_handler()
starts and ends with quotes, they are removed inevaluate_parse_tree()
, and we get a wrong value to evaluate the rest of the formula, with missing quotes.As a reference, here is the definition of the
T()
excel function:The Excel T function returns text when given a text value and an empty string ("") for numbers, dates, and the logical values TRUE and FALSE. You can use the T function to remove values that are not text.
The fix
The fix I'm proposing consists in always wrapping the result of
t_handler()
since it is text by definition. That way we do not loose quotes when unwrapping.