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

Make CompositeType.Members field an ordered map #581

Merged
merged 15 commits into from
Feb 10, 2021
Merged

Conversation

SupunS
Copy link
Member

@SupunS SupunS commented Feb 4, 2021

Description

Work towards #436

  • Introduces a new ordered map with string keys and *Member values
  • Change the type of the CompositeType.Members field to the generated ordered map.

For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@SupunS SupunS force-pushed the supun/ordered-map-2 branch 8 times, most recently from d56c16f to 977b1a1 Compare February 4, 2021 13:53
@SupunS SupunS force-pushed the supun/ordered-map-1 branch from 465709d to be9dbdb Compare February 5, 2021 11:09
@SupunS SupunS marked this pull request as ready for review February 5, 2021 11:22
@SupunS SupunS requested a review from turbolent as a code owner February 5, 2021 11:22
@turbolent turbolent changed the base branch from supun/ordered-map-1 to master February 8, 2021 18:31
@turbolent
Copy link
Member

@SupunS can you please rebase on master?

@SupunS
Copy link
Member Author

SupunS commented Feb 8, 2021

@turbolent Rebased to master.
I force-pushed some commits, that must have made the conflicts :/

Comment on lines 194 to 196
member, ok := t.Members.Get(identifier)

if member.IgnoreInSerialization {
if !ok || member.IgnoreInSerialization {
Copy link
Member

@turbolent turbolent Feb 8, 2021

Choose a reason for hiding this comment

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

Is there ever a case where the lookup would fail? Is it rather an implementation error when the lookup fails?

Same question below.

Copy link
Member Author

Choose a reason for hiding this comment

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

AFAIU Fields are a subset of Members. So the lookup should always succeed.

Maybe a panic would be a good idea.

Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Nice! Just a couple questions / suggestions

runtime/sema/check_composite_declaration.go Outdated Show resolved Hide resolved
runtime/sema/check_transaction_declaration.go Outdated Show resolved Hide resolved
runtime/sema/checker.go Outdated Show resolved Hide resolved
runtime/stdlib/flow.go Outdated Show resolved Hide resolved
testFunctionMember := structureType.Members["test"]

testFunctionMember, ok := structureType.Members.Get("test")
require.True(t, ok)
Copy link
Member

Choose a reason for hiding this comment

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

👍

@turbolent
Copy link
Member

@SupunS thanks for rebasing, looks good

@SupunS SupunS force-pushed the supun/ordered-map-2 branch 4 times, most recently from 1b4def8 to d80fc38 Compare February 9, 2021 13:46
@SupunS SupunS force-pushed the supun/ordered-map-2 branch from d80fc38 to f287790 Compare February 9, 2021 13:48
Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Nice!

runtime/sema/check_composite_declaration.go Show resolved Hide resolved
@SupunS SupunS merged commit 6a0a449 into master Feb 10, 2021
@SupunS SupunS deleted the supun/ordered-map-2 branch February 22, 2021 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants