Different compilation behaviour from native go
flamelx opened this issue · comments
package main
import (
"fmt"
"github.com/cosmos72/gomacro/fast"
)
func main() {
// case1() // as expected
// case2() // panic: expression returns 1 value, expecting 2: "1"
case3() // Different compilation behaviour from native go. Why did the compilation not fail?
}
func case1() {
interp := fast.New()
script := `func Execute()(string,error){
return "1",nil
}`
interp.Eval(script)
vs, _ := interp.Eval("Execute()")
fmt.Println(vs[0].Interface()) // "1"
fmt.Println(vs[1].Interface()) // nil
}
func case2() {
interp := fast.New()
script := `func Execute()(string,error){
return "1"
}`
interp.Eval(script)
vs, _ := interp.Eval("Execute()")
fmt.Println(vs[0].Interface())
fmt.Println(vs[1].Interface())
}
func case3() {
interp := fast.New()
script := `func Execute()(string,error){
}`
interp.Eval(script)
vs, _ := interp.Eval("Execute()")
fmt.Println(vs[0].Interface()) // ""
fmt.Println(vs[1].Interface()) // nil
}
Is this as expected?
Gomacro does not currently report errors for missing return
statements.
So in a sense, yes, this is expected.
Although I am not sure whether it's worth having such a difference from Go toolchain.
Gomacro does not currently report errors for missing
return
statements. So in a sense, yes, this is expected.Although I am not sure whether it's worth having such a difference from Go toolchain.
Thanks, I see.