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.
unnamed and name type support, completed
- Loading branch information
piux2
committed
Sep 17, 2023
1 parent
9f0ff06
commit 6709920
Showing
47 changed files
with
1,046 additions
and
242 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
contracts/assign_unnamed_type/assign_unnamedtype0_filetest.gno
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 | ||
|
||
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
15
contracts/assign_unnamed_type/assign_unnamedtype0b_filetest.gno
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 | ||
|
||
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
15
contracts/assign_unnamed_type/assign_unnamedtype7_filetest.gno
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 | ||
|
||
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) |
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,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) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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,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) |
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,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) |
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,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) |
File renamed without changes.
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,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) |
Oops, something went wrong.