compiler: adjust TestInline template

Move all auxiliary function declaration after Main, so that INITSLOT
instructions counter works properly. `vmAndCompileInterop` loads program
and moves nextIP to the Main function offset if there's no _init
function. If _init is there, then nextIP will be moved to the start of
_init. In TestInline we don't handle instructions properly (CALL/JMP
don't change nextIP), we just perform instruction traversal from the
start point via Next(), thus INITSLOT counter value depends on the
starting instruction, which depends on _init presence.
This commit is contained in:
Anna Shaleva 2022-08-25 12:06:19 +03:00
parent 91b36657d6
commit 1e6b70d570

View file

@ -55,13 +55,13 @@ func TestInline(t *testing.T) {
a int
b pair
}
// local alias
func sum(a, b int) int {
return 42
}
var Num = 1
func Main() int {
%s
}
// local alias
func sum(a, b int) int {
return 42
}`
t.Run("no return", func(t *testing.T) {
src := fmt.Sprintf(srcTmpl, `inline.NoArgsNoReturn()