Improve data type analysis for arbitrary values #9320
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 PR fixes an issue with incorrect splitting of arbitrary values and therefore improving the data type detection so that we require fewer type hints.
The original RegEx did mostly what we want, the idea is that we wanted to split by a
,
but one that was not within()
. This is useful when you define multiple background colors for example:In this case splitting by the regex would result in the proper result:
Visually, you can think of it like:
We properly split by
,
not inside a()
. However, this RegEx fails the moment you have deeply nested,
values or an(
is seen at the right of the current position. If you have the following example:Visually, this is what's happening:
This is because on the right of the
,
, the first paren is an opening paren(
instead of a closing one)
.I'm not 100% sure how we can improve the RegEx to handle that case as well, instead I wrote a small
splitBy
function that allows you to split the string by a character (just like you could do before) but ignores the ones inside the given exceptions. This keeps track of a stack to know whether we are within parens or not.Visually, the fix looks like this: