-
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
feat(compiler): Add feature to insert map from a function result with correct type [LNG-367] #1159
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
29afb2b
add feature to insert map from function with correct type
DieMyst 164cbde
fix compilation
DieMyst 724d741
fix result
DieMyst 8df128e
check warning
DieMyst 39d4901
fix case
DieMyst fa1c446
refactoring DeclareStreamTag
DieMyst 9c31f19
fix unit test
DieMyst d8bd3f7
Merge branch 'main' into LNG-367-insert-from-func
DieMyst 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,20 @@ | ||
aqua StreamMapAbilities | ||
aqua StreamMapTest declares * | ||
|
||
export streamMapAbilityTest | ||
export main | ||
|
||
ability Streams: | ||
stream: *string | ||
map: %string | ||
func foo() -> string, u64: | ||
<- "123", 42 | ||
|
||
ability Adds: | ||
addToStream(s: string) | ||
addToMap(k: string, v: string) | ||
func zzz() -> string, string: | ||
<- "123", "str" | ||
|
||
func addToStreamClosure(str: *string) -> string -> (): | ||
cl = func (s: string): | ||
str <<- s | ||
<- cl | ||
func create() -> %u64: | ||
map: %u64 | ||
map <- foo() | ||
<- map | ||
|
||
func addToMapClosure(str: %string) -> string, string -> (): | ||
cl = func (k: string, v: string): | ||
str <<- k, v | ||
<- cl | ||
func main(): | ||
map <- create() | ||
a <- zzz() | ||
|
||
func addTo{Streams}() -> Adds: | ||
addStream = addToStreamClosure(Streams.stream) | ||
addMap = addToMapClosure(Streams.map) | ||
adds = Adds(addToStream = addStream, addToMap = addMap) | ||
<- adds | ||
|
||
func add{Adds}(s: string, k: string): | ||
Adds.addToStream(s) | ||
Adds.addToMap(k, k) | ||
|
||
func streamMapAbilityTest() -> []string, []string: | ||
stream: *string | ||
map: %string | ||
ab = Streams(stream = stream, map = map) | ||
adds <- addTo{ab}() | ||
add{adds}("one", "1") | ||
add{adds}("two", "2") | ||
add{adds}("three", "3") | ||
<- stream, map.keys() | ||
map <- foo() |
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -398,6 +398,8 @@ case class StreamMapType(override val element: DataType) extends MutableStreamTy | |
StructType(name, NonEmptyMap.of("key" -> ScalarType.string, "value" -> element)) | ||
|
||
def toCanon: ImmutableCollectionType = CanonStreamMapType(element) | ||
|
||
def toProduct: ProductType = ProductType(ScalarType.string :: element :: Nil) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I would call it |
||
} | ||
|
||
object StreamMapType { | ||
|
Oops, something went wrong.
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.
This guard does not help, as it is after the main case above, it should be before.
This code produces incorrect AIR:
AIR:
(ap (%map 42) %m)