Skip to content
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 8 commits into from
Jul 1, 2024

Conversation

DieMyst
Copy link
Member

@DieMyst DieMyst commented Jun 19, 2024

Description

Make it possible to push a key and a value into stream maps as it is in streams:

func foo() -> string, u64:
  <- "123", 42

func create() -> %u64:
  map: %u64
  map <- foo()
  <- map

Checklist

  • Corresponding issue has been created and linked in PR title.
  • Proposed changes are covered by tests.
  • Documentation has been updated to reflect the changes (if applicable).
  • I have self-reviewed my code and ensured its quality.
  • I have added/updated necessary comments to aid understanding.

Reviewer Checklist

  • Tests have been reviewed and are sufficient to validate the changes.
  • Documentation has been reviewed and is up to date.
  • Any questions or concerns have been addressed.

Copy link

linear bot commented Jun 19, 2024

@DieMyst DieMyst added the e2e Run e2e workflow label Jun 19, 2024
@DieMyst DieMyst changed the title feat(compiler): Add feature to insert map from a function result with correct type feat(compiler): Add feature to insert map from a function result with correct type [LNG-367] Jun 19, 2024
@DieMyst DieMyst marked this pull request as ready for review June 21, 2024 04:51
@DieMyst DieMyst requested a review from InversionSpaces June 21, 2024 04:51
case (
CallModel.Export(n, StreamMapType(_)),
(res @ VarModel(_, StreamMapType(_), _), resDesugar)
) if !outsideStreamNames.contains(n) =>
Copy link
Contributor

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:

func foo() -> %string, u64:
  map: %string
  <- map, 42

func main() -> string:
  m <- foo()
  <- m.get("key")!

AIR: (ap (%map 42) %m)

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would call it elementProduct, bc it is unclear on the first glance how to transform map type to product

@DieMyst DieMyst requested a review from InversionSpaces June 21, 2024 10:44
@DieMyst DieMyst merged commit 4d49279 into main Jul 1, 2024
9 checks passed
@DieMyst DieMyst deleted the LNG-367-insert-from-func branch July 1, 2024 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e Run e2e workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants