WAT: Bug in function number
Code:
program test_c_interface
integer , parameter :: i_max = 600
integer , parameter :: j_max = 450
integer :: image_t(j_max, i_max)
interface
subroutine show_img(n, m, A) bind(c)
integer, intent(in) :: n, m
integer, intent(in) :: A(3,n,m)
end subroutine
end interface
call show_img(j_max, i_max, image_t)
end program mandelbrot
output:
$ lfortran --show-wat b.f90
(module
(type (;0;) (func (param i32) (result)))
(type (;1;) (func (param i64) (result)))
(type (;2;) (func (param f32) (result)))
(type (;3;) (func (param f64) (result)))
(type (;4;) (func (param i32 i32) (result)))
(type (;5;) (func (param) (result)))
(type (;6;) (func (param i32) (result)))
(type (;7;) (func (param i32 i32 i32) (result)))
(type (;8;) (func (param) (result)))
(import "js" "print_i32" (func (;0;) (type 0)))
(import "js" "print_i64" (func (;1;) (type 1)))
(import "js" "print_f32" (func (;2;) (type 2)))
(import "js" "print_f64" (func (;3;) (type 3)))
(import "js" "print_str" (func (;4;) (type 4)))
(import "js" "flush_buf" (func (;5;) (type 5)))
(import "js" "set_exit_code" (func (;6;) (type 6)))
(import "js" "memory" (memory (;0;) 100 100))
(import "js" "show_img" (func (;8;) (type 7)))
(func $8 (type 8) (param) (result)
(local i32 i32 i32)
i32.const 600
local.set 0
i32.const 0
local.set 1
i32.const 450
local.set 2
local.get 2
local.get 0
local.get 1
call 7
i32.const 0
call 6
return
)
(export "_lcompilers_main" (func $8))
)
Bug:
We should have (import "js" "show_img" (func (;7;) (type 7))
with 7 instead of 8,