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

Concretize the definition of Primitive type #2975

Merged
merged 7 commits into from
Dec 15, 2023

Conversation

darkdrag00nv2
Copy link
Contributor

@darkdrag00nv2 darkdrag00nv2 commented Dec 11, 2023

Work towards #2929

For earlier discussions, please check - #2962

Description

This PR concretizes the definition of Primitive type by introducing a IsPrimitiveType function on sema.Type.

The following types have been marked as primitive:

  • Number types
  • Character
  • Bool
  • String
  • Address
  • Path
  • Void
  • Optional<T> - if T is primitive

  • 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

@darkdrag00nv2 darkdrag00nv2 changed the title Define primitives Concretize the definition of Primitive type Dec 11, 2023
@darkdrag00nv2
Copy link
Contributor Author

@turbolent Could you please suggest the kind of test cases that make sense here for this? This is in regards to your comment here: #2962 (comment)

Copy link

codecov bot commented Dec 11, 2023

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (0de878b) 80.12% compared to head (d34c63c) 80.15%.
Report is 9 commits behind head on master.

Files Patch % Lines
runtime/sema/gen/main.go 44.44% 4 Missing and 1 partial ⚠️
runtime/sema/type.go 94.59% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2975      +/-   ##
==========================================
+ Coverage   80.12%   80.15%   +0.02%     
==========================================
  Files         348      348              
  Lines       81796    81970     +174     
==========================================
+ Hits        65537    65699     +162     
- Misses      13939    13950      +11     
- Partials     2320     2321       +1     
Flag Coverage Δ
unittests 80.15% <85.41%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@turbolent
Copy link
Member

@turbolent Could you please suggest the kind of test cases that make sense here for this? This is in regards to your comment here: #2962 (comment)

Maybe just add some unit tests to sema/type_test.go, which instantiate each type, call the new IsPrimitiveType function, and assert the expected value. Similar to e.g. TestCommonSuperType

@turbolent turbolent self-assigned this Dec 11, 2023
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! Should be ready to get merged once the test have been added

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!

@darkdrag00nv2
Copy link
Contributor Author

@dsainati1 @SupunS Can you please review and then merge this if it looks good? It will unblock #2803 for me. Thanks!

@SupunS SupunS merged commit f94e4d0 into onflow:master Dec 15, 2023
@darkdrag00nv2 darkdrag00nv2 deleted the define_primitives branch December 16, 2023 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants