compiler: extend possible returned values
All integer values (int32, uint64...) should be able to be returned.
This commit is contained in:
parent
7e98a2ffa0
commit
bfcb1a409f
2 changed files with 11 additions and 1 deletions
|
@ -123,7 +123,9 @@ func (c *codegen) emitLoadConst(t types.TypeAndValue) {
|
||||||
|
|
||||||
func (c *codegen) convertBasicType(t types.TypeAndValue, typ *types.Basic) {
|
func (c *codegen) convertBasicType(t types.TypeAndValue, typ *types.Basic) {
|
||||||
switch typ.Kind() {
|
switch typ.Kind() {
|
||||||
case types.Int, types.UntypedInt, types.Uint:
|
case types.Int, types.UntypedInt, types.Uint,
|
||||||
|
types.Int16, types.Uint16,
|
||||||
|
types.Int32, types.Uint32, types.Int64, types.Uint64:
|
||||||
val, _ := constant.Int64Val(t.Value)
|
val, _ := constant.Int64Val(t.Value)
|
||||||
emit.Int(c.prog.BinWriter, val)
|
emit.Int(c.prog.BinWriter, val)
|
||||||
case types.String, types.UntypedString:
|
case types.String, types.UntypedString:
|
||||||
|
|
|
@ -5,6 +5,14 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestReturnInt64(t *testing.T) {
|
||||||
|
src := `package foo
|
||||||
|
func Main() int64 {
|
||||||
|
return 1
|
||||||
|
}`
|
||||||
|
eval(t, src, big.NewInt(1))
|
||||||
|
}
|
||||||
|
|
||||||
func TestMultipleReturn1(t *testing.T) {
|
func TestMultipleReturn1(t *testing.T) {
|
||||||
src := `
|
src := `
|
||||||
package hello
|
package hello
|
||||||
|
|
Loading…
Reference in a new issue