Skip to content

Commit

Permalink
unnamed and name type support, completed
Browse files Browse the repository at this point in the history
  • Loading branch information
piux2 committed Sep 17, 2023
1 parent 9f0ff06 commit 6709920
Show file tree
Hide file tree
Showing 47 changed files with 1,046 additions and 242 deletions.
15 changes: 15 additions & 0 deletions contracts/assign_unnamed_type/assign_unnamedtype0_filetest.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main

type nat []word
type word int

func main() {
var a nat
b := []word{0}
a = b

println(a)
}

// Output:
// (slice[(0 main.word)] main.nat)
15 changes: 15 additions & 0 deletions contracts/assign_unnamed_type/assign_unnamedtype0b_filetest.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main

type nat []int
type word int

func main() {
var a nat
b := []word{0}
a = b

println(a)
}

// Error:
// main/contracts/assign_unnamed_type/assign_unnamedtype0b_filetest.gno:9: cannot use main.word as int without explicit conversion
15 changes: 15 additions & 0 deletions contracts/assign_unnamed_type/assign_unnamedtype7_filetest.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main

type mychan chan int

// chan int is unmamed
func main() {
var n mychan = nil
var u chan int = nil
n = u

println(n)
}

// Output:
// (nil main.mychan)
20 changes: 20 additions & 0 deletions contracts/declaredtype/declaredType0b_filetest.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package main

type word int
type nat []word

func (n nat) add() bool {
return true
}

func main() {
var abs nat
var b []word
b = []word{0}
abs = b

println(abs)
}

// Output:
// (slice[(0 main.word)] main.nat)
20 changes: 0 additions & 20 deletions contracts/decompose/decompose2_filetest.gno

This file was deleted.

20 changes: 0 additions & 20 deletions contracts/decompose/decompose_filetest.gno

This file was deleted.

26 changes: 26 additions & 0 deletions contracts/decompose/decompose_unnamed1a_filetest.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

type nat []int

func x() (nat, []int) {
a := nat{1}
b := []int{2}
return a, b
}

func main() {
var u1 []int
var n2 nat

_, n2 = x()
// _tmp1, _tmp_2 := x()
// _, u2 = _tmp1, _tmp_2

println(u1)
println(n2)

}

// Output:
// (nil []int)
// (slice[(2 int)] main.nat)
26 changes: 26 additions & 0 deletions contracts/decompose/decompose_unnamed1b_filetest.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

type nat []int

func x() (nat, []int) {
a := nat{1}
b := []int{2}
return a, b
}

func main() {
var u1 []int
var n2 nat

u1, _ = x()
// _tmp1, _tmp_2 := x()
// u1, _ = _tmp1, _tmp_2

println(u1)
println(n2)

}

// Output:
// slice[(1 int)]
// (nil main.nat)
30 changes: 30 additions & 0 deletions contracts/decompose/decompose_unnamed2_filetest.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

type nat []int

func x() (nat, []int) {
a := nat{1}
b := []int{2}
return a, b
}

func main() {
var u1 []int
var n2 nat
// BlockStmt
{ u1, n2 = x()
// _tmp_1, _tmp_2 := x()
// u1, n2 = _tmp_1, _tmp_2

println(u1)
println(n2)
println(u1)
println(n2)
}
}

// Output:
// slice[(1 int)]
// (slice[(2 int)] main.nat)
// slice[(1 int)]
// (slice[(2 int)] main.nat)
30 changes: 30 additions & 0 deletions contracts/filetest/default_value_filetest.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main
type nat []int
type nmap map[int]int
type nfunc func()

func main() {
var u1 []int
var n2 nat
var m map[int]int
var m2 nmap
var f func()
var f2 nfunc


println(u1)
println(n2)
println(m)
println(m2)
println(f)
println(f2)

}

// Output:
// (nil []int)
// (nil main.nat)
// (nil map[int]int)
// (nil main.nmap)
// nil func()()
// (nil main.nfunc)
Loading

0 comments on commit 6709920

Please sign in to comment.