decoder: Introduce helper functions for completion inside ObjectConsExpr
#211
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 introduces two small helper functions decoupled from a few discovered use cases / PRs:
TypeDeclaration
asConstraint
#183 (forobject({ ... })
)LiteralType
asConstraint
#186 (throughObject
orMap
)Map
asConstraint
#199Object
asConstraint
#203AnyExpression
constraintThe last attached test case illustrates an example of the problem.
Implementation Notes
Our use cases don't actually involve multi-byte runes, so in theory we could be just comparing single bytes and avoid the decoding, but that then makes the consumer side a bit more verbose since
'\n'
would need to be written e.g. asbyte('\n')
. We could technically allow runes and treat them like single bytes, but that just feels wrong.Since we'd usually seek through relatively small slice, the decoding is unlikely to pose performance issue, but we can revisit the solution if it does.