-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Type refinements #162
Closed
Closed
Type refinements #162
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
50e9164
Add parent type argument to NullaryType
Avaq e983ea2
Reorder types based on new ordering scheme
Avaq c5f1130
Add refinement support to UnaryType constructor
Avaq 90b7aa3
Add refinement support to BinaryType constructor
Avaq fa55a10
Remove no longer necessary null-check
Avaq 75a55dd
Incorporate PR feedback
Avaq aada3db
Add refinement support to RecordType constructor
Avaq 96d562c
Document how to use record type refinement
Avaq 7b0ac2c
Incorporate PR feedback
Avaq 6d6960b
:warning: Change env from Array Any to Array Type
Avaq 02ea18c
Rephrase the documentation using "one" over "we"
Avaq 017a376
Add assertions for record extension
Avaq 1ae62f4
Aleviate minor complaints about documentation
Avaq 4b90668
In-line Options record definition with create definition
Avaq 9708db1
Add Strict type constructor
Avaq cc92cd2
Rephrase documentation on additional record fields
Avaq 2fce7d9
Incorporate PR feedback
Avaq f1da1c4
Take all enumerable properties into account for strict record types
Avaq e08290c
Let record and strict types acknowledge all enumerable properties
Avaq 7b57bc0
WIP: Level Strict and NonEmpty in terms of approach
Avaq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
parent
as an actual parent type, like I'm doing here, seems like a good idea. NowNonEmpty String
will (correctly) be a "refinement" ofString
.However, as indicated by the failing unit test, it causes a value of
[1]
for$NonEmpty($Array($String))
, for example, to generate this error message:Where we would want:
I'm not sure why this happens. Replacing
parent
withAny
solves the issue.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that
evaluates to
['$1']
rather than['$1', '$1']
because we first validate the parent type and, if validation fails, make no adjustment topropPath
to account for the extra level of nesting introduced by$.NonEmpty
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems like an issue that will bite us in some other way, one day. I don't yet see a solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In it's general form, I think the issue could be described as: When the validation of a refined type fails on its parent type, the reported
propPath
may not correctly correspond to the location of the value as it exists in the refined typeWe even encounter this issue if we refine a record type to be "strict", as has always been the suggestion:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same problem, biting us somewhere else:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is particularly problematic, because the property names described by
propPath
might exist in both the parent type and the refinement, andvalidate
does not tell us which it was.