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

feat(gnovm): sync code AssignStmt - ValueDecl #3017

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
297dd6d
chore: refactor DRY code
hthieu1110 Oct 23, 2024
6e6bcae
wip
Oct 24, 2024
f196044
wip: sync AssignStmt DEFINE with ValueDecl
hthieu1110 Oct 24, 2024
efc7467
Merge remote-tracking branch 'remote/master' into feat/sync-assignstm…
Oct 25, 2024
26792b5
fix: use tupletype for evalStaticTypeOfRaw for CallExpr
Oct 25, 2024
551ab25
wip: sync the general case
Oct 25, 2024
d7401c0
feat: refactor general case code for AssignStmt vs ValueDecl
hthieu1110 Oct 25, 2024
96f279c
chore: remove unused codes + file
hthieu1110 Oct 25, 2024
e54abf8
Merge branch 'master' into feat/sync-assignstmt-valuedecl-1958
hthieu1110 Oct 25, 2024
b050dc6
Merge remote-tracking branch 'remote/master' into feat/sync-assignstm…
hthieu1110 Oct 26, 2024
81b6be5
chore: optimize numNames check
hthieu1110 Oct 26, 2024
1d95d48
chore: add more tests
hthieu1110 Oct 26, 2024
0cf7ca1
Merge remote-tracking branch 'remote/master' into feat/sync-assignstm…
hthieu1110 Oct 28, 2024
edd2287
chore: refactor tests
hthieu1110 Oct 28, 2024
5ecc039
feat: refactor defineOrDecl to raise the same error + add more tests
hthieu1110 Oct 28, 2024
0e80d12
fix: fix tests
hthieu1110 Oct 28, 2024
f3e021f
chore: optimize code
hthieu1110 Oct 30, 2024
f57aafa
Merge remote-tracking branch 'remote/master' into feat/sync-assignstm…
hthieu1110 Oct 30, 2024
937f0b2
Merge remote-tracking branch 'remote/master' into feat/sync-assignstm…
hthieu1110 Oct 30, 2024
c4398a2
Merge branch 'master' into feat/sync-assignstmt-valuedecl-1958
hthieu1110 Nov 1, 2024
67c1dce
Merge branch 'master' into feat/sync-assignstmt-valuedecl-1958
hthieu1110 Nov 5, 2024
234e028
fix: addresses all comments + add tests
Nov 6, 2024
4145083
fix: check compat with given type vs tuple type
Nov 6, 2024
daf9766
fix: fix type compare using kind to cover custom type
Nov 6, 2024
272187f
Merge remote-tracking branch 'remote/master' into feat/sync-assignstm…
Nov 7, 2024
2e199b4
chore: fix typos
Nov 7, 2024
89646d8
chore: remove unneeded comments
Nov 7, 2024
f552c29
test: test CI
Nov 7, 2024
d60ec6c
fix: try to fix CI
Nov 7, 2024
15f8a43
fix: resolve conflict
Nov 8, 2024
aeca442
fix: use checkAssignableTo instead of type comparison + update tests
Nov 8, 2024
6d200db
fix: make error more explicit + use skipFile
Nov 8, 2024
b354cfd
Merge branch 'master' into feat/sync-assignstmt-valuedecl-1958
hthieu1110 Nov 11, 2024
52a42f6
Merge branch 'master' into feat/sync-assignstmt-valuedecl-1958
hthieu1110 Nov 13, 2024
4adcf7b
Merge branch 'master' into feat/sync-assignstmt-valuedecl-1958
hthieu1110 Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
411 changes: 219 additions & 192 deletions gnovm/pkg/gnolang/preprocess.go

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions gnovm/tests/files/assign25c.gno
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)
15 changes: 15 additions & 0 deletions gnovm/tests/files/assign25d.gno
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)
22 changes: 22 additions & 0 deletions gnovm/tests/files/assign32.gno
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
13 changes: 13 additions & 0 deletions gnovm/tests/files/assign33.gno
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
mvertes marked this conversation as resolved.
Show resolved Hide resolved
14 changes: 14 additions & 0 deletions gnovm/tests/files/assign34.gno
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

14 changes: 14 additions & 0 deletions gnovm/tests/files/assign35.gno
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
19 changes: 19 additions & 0 deletions gnovm/tests/files/assign36.gno
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
15 changes: 15 additions & 0 deletions gnovm/tests/files/var22c.gno
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)>
Loading