The module below has two function types declared, `0: () -> ()` and `1: (i32) -> ()`. It also has a single function defined with the second function type i.e. `(i32) -> ()`. That function has a single local defined. Since it has a parameter, my understanding is that the local should have the index 1 in the "Code Disassembly" section of wasm-objdump, but instead has the index 0:

```
module.wasm:	file format wasm 0x1

Section Details:

Type[2]:
 - type[0] () -> nil
 - type[1] (i32) -> nil
Function[1]:
 - func[0] sig=1 <f1>
Code[1]:
 - func[0] size=4 <f1>
Custom:
 - name: "name"
 - func[0] <f1>
 - func[0] local[0] <paramA>
 - func[0] local[1] <localA>
Custom:
 - name: "linking"
  - symbol table [count=1]
   - 0: F <f1> func=0 [ binding=global vis=default ]

Code Disassembly:

00002a func[0] <f1>:
 00002b: 01 7e                      | local[0] type=i64
 00002d: 0b                         | end
```

Removing the first type (`() -> ()`) results in the local having the index 1, as I'd expect.

Looking through the code, I believe the issue is that in `binary-reader-objdump.cc`:

* In `OnFuncType`, we have:
   ```cpp
   objdump_state_->function_param_counts[index] = param_count;
   ```
   where `index` is the index of the type i.e. we treat the keys of `function_param_counts` as type indices.

* In `BeginFunctionBody`, we have:
   ```cpp
   local_index_ = objdump_state_->function_param_counts[index];
   ```
   where `index` is the index of the function i.e. we treat the keys of `function_param_counts` as function indices.

This seems to be consistent with the output I'm seeing.

It's entirely possible I've misunderstood something, so please feel free to correct me! If my diagnosis is correct, I'm happy to try putting together a fix, but I'm equally happy if it's simpler for someone else to write one.

[module.zip](https://github.com/WebAssembly/wabt/files/11886114/module.zip)

wasm-objdump has incorrect local numbering
This is a GitHub Issue
repo:wabt
owner:WebAssembly
Title : wasm-objdump has incorrect local numbering
Issue date:

--- start body ---
The module below has two function types declared, `0: () -> ()` and `1: (i32) -> ()`. It also has a single function defined with the second function type i.e. `(i32) -> ()`. That function has a single local defined. Since it has a parameter, my understanding is that the local should have the index 1 in the "Code Disassembly" section of wasm-objdump, but instead has the index 0:

```
module.wasm:	file format wasm 0x1

Section Details:

Type[2]:
 - type[0] () -> nil
 - type[1] (i32) -> nil
Function[1]:
 - func[0] sig=1 <f1>
Code[1]:
 - func[0] size=4 <f1>
Custom:
 - name: "name"
 - func[0] <f1>
 - func[0] local[0] <paramA>
 - func[0] local[1] <localA>
Custom:
 - name: "linking"
  - symbol table [count=1]
   - 0: F <f1> func=0 [ binding=global vis=default ]

Code Disassembly:

00002a func[0] <f1>:
 00002b: 01 7e                      | local[0] type=i64
 00002d: 0b                         | end
```

Removing the first type (`() -> ()`) results in the local having the index 1, as I'd expect.

Looking through the code, I believe the issue is that in `binary-reader-objdump.cc`:

* In `OnFuncType`, we have:
   ```cpp
   objdump_state_->function_param_counts[index] = param_count;
   ```
   where `index` is the index of the type i.e. we treat the keys of `function_param_counts` as type indices.

* In `BeginFunctionBody`, we have:
   ```cpp
   local_index_ = objdump_state_->function_param_counts[index];
   ```
   where `index` is the index of the function i.e. we treat the keys of `function_param_counts` as function indices.

This seems to be consistent with the output I'm seeing.

It's entirely possible I've misunderstood something, so please feel free to correct me! If my diagnosis is correct, I'm happy to try putting together a fix, but I'm equally happy if it's simpler for someone else to write one.

[module.zip](https://github.com/WebAssembly/wabt/files/11886114/module.zip)

--- end body ---
