Fix record cast with named record type#7185
Open
bentsherman wants to merge 1 commit into
Open
Conversation
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
✅ Deploy Preview for nextflow-docs-staging canceled.
|
6 tasks
Contributor
|
In my opinion, this behaviour is strange or at least incomplete; a user could do something like this: You create a record, cast it to |
Member
Author
|
Good catch. I actually meant to implement a compiler transform for that as well, so that I will try to implement that in this PR |
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 PR fixes the use of casting records to a named record type, for example:
workflow { record(id: '1', fastq: file('1.fastq')) as Sample } record Sample { id: String fastq: Path }Casting a record to a named record type should be a no-op at runtime. It is only used by the type checker to validate that the record satisfies the requirements of the record type.
If the cast is is not removed at runtime, the record would be cast to an instance of
Sample, since record types are compiled to actual classes at runtime with an implicit constructor. This would break the runtime's assumption that all records areRecordMaps.