-
Notifications
You must be signed in to change notification settings - Fork 136
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
Use common super-type for expression type inferring #1027
Conversation
b0d42b2
to
5ca55cb
Compare
6ce5a41
to
ea32ec5
Compare
ca1a55e
to
d362440
Compare
d39e167
to
cc3c169
Compare
cc3c169
to
8a5de64
Compare
351fdf6
to
56f6e53
Compare
…cadence into supun/common-supertype-usages
@@ -233,41 +231,6 @@ func (checker *Checker) recordVariableDeclarationRange( | |||
) | |||
} | |||
|
|||
func (checker *Checker) checkVariableDeclarationUsability(declaration *ast.VariableDeclaration) { |
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 check now happens at the expression level for arrays/dictionaries. Because:
- Need to infer the type even in non-variable-delectation scenarios. e.g: the expression
[].getType()
should have a type inferred for the empty array. - Even if the array is not empty, there could be non-inferrable scenarios
e.g:[<some_struct>, <some_resource>]
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.
Nice!
…cadence into supun/common-supertype-usages
…/common-supertype-usages
Cadence Benchstat comparisonThis branch with compared with the base branch onflow:master commit 81f00f2 Results
|
Codecov Report
@@ Coverage Diff @@
## master #1027 +/- ##
==========================================
+ Coverage 77.53% 77.59% +0.06%
==========================================
Files 274 274
Lines 35085 35241 +156
==========================================
+ Hits 27204 27347 +143
- Misses 6801 6809 +8
- Partials 1080 1085 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
Very nice work! 👏
Co-authored-by: Bastian Müller <bastian@axiomzen.co>
…flow/cadence into supun/common-supertype-usages
da9d200
to
a961aae
Compare
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.
Great work! 👏
Closes #61
Closes #1239
Description
This PR adds support for inferring the common supertype for:
Breaking Changes
With these changes, array literals and dictionary literals no longer use the first element to infer the type for the literal. Thus, if it requires a literal to have a certain specific type, then explicit type annotation or casting must be used.
e.g:
Old way
New Way
master
branchFiles changed
in the Github PR explorer