forked from gnolang/gno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: named and unnamed type assignment 2 of 3 (gnolang#1246)
This is part 2 of 3 of the solution for issue gnolang#1141. The part 1 of 3 of the solution can be found in issue gnolang#1143. In this part of the solution, we have made several improvements: - Support both named and unnamed type assignments in assignment statements and function return values. - Resolved the issue related to incorrect method selectors that is caused by mixing named and unnamed assignments. - Added 62 file tests to ensure the correctness of the code. - Included 2 realm tests to further validate the cross realm assignment and method selector. - Enhanced the support for GNO file tests in nested directories. This allows us to organize tests in intuitively named folders. To achieve the above improvements in the preprocessing phase, we made the following changes: - Introduced an isNamed() function on the Type Interface and marked named types with isNamed() returning true. This helps distinguish between named and unnamed types. - Followed the specifications to convert the right-hand side type into a constant function type. - As for determining the package associated with a test file, we've maintained the original convention. We keeps relying on the comment directive "//PKGPATH: gno.land/r/xyz" in the test file itself to identify the package it belongs to. We do not using the local folder structure to derive the package for file tests. Therefore the tests in tests/files folder can be stored in any intuitively named sub directories. **NOTE:** The named and unnamed type conversions that involve the decomposition of function calls returning multiple values in the preprocess have not yet been included in this pull request. This functionality will be addressed in part 3 of 3 of the entire solution. <!-- please provide a detailed description of the changes made in this pull request. --> <details><summary>Contributors' checklist...</summary> - [x] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [x] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details> --------- Co-authored-by: deelawn <dboltz03@gmail.com> Co-authored-by: Morgan Bazalgette <morgan@morganbaz.com>
- Loading branch information
1 parent
11c8b6c
commit fed3e9e
Showing
75 changed files
with
2,434 additions
and
89 deletions.
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package tests | ||
|
||
type ( | ||
Word uint | ||
nat []Word | ||
) | ||
|
||
var zero = &Int{ | ||
neg: true, | ||
abs: []Word{0}, | ||
} | ||
|
||
// structLit | ||
type Int struct { | ||
neg bool | ||
abs nat | ||
} | ||
|
||
func GetZeroType() nat { | ||
a := zero.abs | ||
return a | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package tests | ||
|
||
var abs nat | ||
|
||
func (n nat) Add() nat { | ||
return []Word{0} | ||
} | ||
|
||
func GetAbs() nat { | ||
abs = []Word{0} | ||
|
||
return abs | ||
} | ||
|
||
func AbsAdd() nat { | ||
rt := GetAbs().Add() | ||
|
||
return rt | ||
} |
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
Oops, something went wrong.