-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gnovm): sync code AssignStmt - ValueDecl (#3017)
This PR aims at fixing this issue [1958](#1958) <!-- please provide a detailed description of the changes made in this pull request. --> <details><summary>Contributors' checklist...</summary> - [ ] 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 - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests </details> --------- Co-authored-by: hieu.ha <[email protected]> Co-authored-by: Mikael VALLENET <[email protected]>
- Loading branch information
1 parent
7718bc3
commit dc65f91
Showing
9 changed files
with
342 additions
and
192 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,15 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func f() (a, b int) { | ||
return 1, 2 | ||
} | ||
|
||
func main() { | ||
x, y, z := 1, f() | ||
fmt.Println(x, y, z) | ||
} | ||
|
||
// Error: | ||
// main/files/assign25c.gno:10:2: assignment mismatch: 3 variable(s) but 2 value(s) |
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,15 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func f() (a, b int) { | ||
return 1, 2 | ||
} | ||
|
||
func main() { | ||
x, y, z := f(), 1, 2, 3 | ||
fmt.Println(x, y, z) | ||
} | ||
|
||
// Error: | ||
// main/files/assign25d.gno:10:2: assignment mismatch: 3 variable(s) but 4 value(s) |
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 main | ||
|
||
func foo() int { | ||
return 2 | ||
} | ||
|
||
func main() { | ||
var mp map[string]int = map[string]int{"idx": 4} | ||
var sl []int = []int{4, 5, 6} | ||
arr := [1]int{7} | ||
var num interface{} = 5 | ||
|
||
a, b, c, d, e, f, g := int(1), foo(), 3, mp["idx"], num.(int), sl[2], arr[0] | ||
println(a, b, c, d, e, f, g) | ||
|
||
var h, i, j, k, l, m, n int = int(1), foo(), 3, mp["idx"], num.(int), sl[2], arr[0] | ||
println(h, i, j, k, l, m, n) | ||
} | ||
|
||
// Output: | ||
// 1 2 3 4 5 6 7 | ||
// 1 2 3 4 5 6 7 |
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,13 @@ | ||
package main | ||
|
||
func foo() (int, bool) { | ||
return 1, true | ||
} | ||
|
||
func main() { | ||
var a, b int = foo() | ||
println(a, b) | ||
} | ||
|
||
// Error: | ||
// main/files/assign33.gno:8:6: cannot use foo<VPBlock(3,0)>() (value of type bool) as int value in assignment |
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,14 @@ | ||
package main | ||
|
||
func foo() (int, bool) { | ||
return 1, true | ||
} | ||
|
||
func main() { | ||
var a, b = foo() | ||
println(a, b) | ||
} | ||
|
||
// Output: | ||
// 1 true | ||
|
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,14 @@ | ||
package main | ||
|
||
func foo() (int, bool) { | ||
return 1, true | ||
} | ||
|
||
func main() { | ||
a, b := 2, foo() | ||
|
||
println(a, b) | ||
} | ||
|
||
// Error: | ||
// main/files/assign35.gno:8:2: multiple-value foo<VPBlock(3,0)> (value of type [int bool]) in single-value context |
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 main | ||
|
||
import "fmt" | ||
|
||
func f() (int) { | ||
return 2 | ||
} | ||
|
||
func main() { | ||
var a, b, c = 1, f(), 3 | ||
fmt.Println(a, b, c) | ||
|
||
x, y, z := 1, f(), 3 | ||
fmt.Println(x, y, z) | ||
} | ||
|
||
// Output: | ||
// 1 2 3 | ||
// 1 2 3 |
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,15 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func f() (a, b int) { | ||
return 1, 2 | ||
} | ||
|
||
func main() { | ||
var x, y, z = 1, f() | ||
fmt.Println(x, y, z) | ||
} | ||
|
||
// Error: | ||
// main/files/var22c.gno:10:6: missing init expr for z<!VPUverse(0)> |