[WebAssembly] Fix type index block type handling in type checker
authorHeejin Ahn <aheejin@gmail.com>
Sat, 8 Apr 2023 03:29:25 +0000 (20:29 -0700)
committerHeejin Ahn <aheejin@gmail.com>
Tue, 11 Apr 2023 09:04:56 +0000 (02:04 -0700)
commit8c0798f368356e50f59a2598b28e7cac8770ea4c
tree918545187172f1a809d73e9491a5696729bc71a6
parentd0027e0be990df60f6f826123f035286a168f288
[WebAssembly] Fix type index block type handling in type checker

The current code is
```
      ExpectBlockType = false;
      TC.setLastSig(*Signature.get());
      if (ExpectBlockType)
        NestingStack.back().Sig = *Signature.get();
```

Because of the first line, the third line's `if (ExpectBlockType)` is
always false and we don't get to update `NestingStack.back().Sig`. This
results in not correctly erroring out when the types of remaining values
on the stack do not match the block type if the block type is written in
the form of a function type. We should set `ExpectBlockType` to false
after the `if`.

Reviewed By: sbc100

Differential Revision: https://reviews.llvm.org/D147837
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
llvm/test/MC/WebAssembly/type-checker-errors.s