Conversation
Avoids infinite loop for the following code snippet:
```ftd
-- test:
a: Hello
-- component test:
string a:
-- ftd.text: Test
classes: $test.a
-- end: test
```
`classes` of `ftd.text` component takes a list of string but ftd has a
feature that turns T -> List<T> if expected kind is List<T> and found
kind is T.
This works for single literals, like:
```
-- ftd.text: something
classes: one
```
The string literal `one` is converted to List<String> because `classes`
expects that.
This, for some reason, does not work when we use a variable reference
instead of literals. This changes fixes this case.
NOTE: This change does not support mixing of two styles, you can't do:
```ftd
-- test:
a: two
-- component test:
string a:
-- ftd.text: Test
classes: one, $test.a ;; SEE THIS!
-- end: test
```
This still results in a Cycle Detection error:
```
failed to parse FoundCycle { message: \"test#test:4 => test#test:4 => test#test:4\", line_number: 4 }
```
Simply removing this match branch and failing with a "expected_kind and
found_kind mismatch" error is not an option here as it'll break so many
existing packages in the world.
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an infinite loop when wrapping a variable reference into a list for a property that expects List<T> by returning a single-element list containing the reference instead of an empty value.
- Converts a reference to a
List<T>whenexpected_kindis a list andfound_kindmatches the inner type. - Uses
get_reference_nameandget_kindto construct the wrapped list value. - Maintains existing behavior for literals and avoids breaking other use cases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 fixes #2169
Avoids infinite loop for the following code snippet:
classesofftd.textcomponent takes a list of string but ftd has a feature that turnsT->List<T>if expected kind isList<T>and found kind isT.This works for single literals, like:
The string literal
oneis converted toList<String>becauseclassesexpects that.This, for some reason, does not work when we use a variable reference instead of literals. This change fixes this case.
NOTE: This change does not support mixing of two styles, you can't do:
This still results in a Cycle Detection error:
Simply removing this match branch and failing with a "expected_kind and found_kind mismatch" error is not an option here as it'll break so many existing packages in the world.