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 does two things:
Add an impossible
never
type when removing record methodsExample:
This makes sure that the returned
y
value never has anyfoo
orgni
method, which is the runtime behavior.Before that, the following was a correct function:
Add syntactic sugar for record and record pattern spread
These spread patterns are much more common nowadays and will help programmers being more confident in learning and understanding the language.
Ideally, we would like the spread to only apply to records (unit values with methods) and not other values, for instance:
However, I don't think that this is currently possible with the existing type system because we need to keep the root type universal in case this becomes wrapped into a function:
There isn't a way currently to both say that
y
should be a record and that it should retain all the other methods fromx
. This might be possible with e.g. a constraint but I didn't want to enter that territory yet as I believe non-unit values with methods are still pretty advanced so why not let the advanced programmer know what they are doing?