validate table type for call_indirect

This commit is contained in:
Ilya Rezvov
2025-01-15 17:26:16 -07:00
parent 78a2f33176
commit 64e2e14562
+2
View File
@@ -278,6 +278,8 @@ getInstrType _ (CallIndirect tableIdx sign) = do
if length tables <= fromIntegral tableIdx
then throwError (TableIndexOutOfRange tableIdx)
else do
let TableType _ elemType = tables !! fromIntegral tableIdx
when (elemType /= FuncRef) $ throwError (RefTypeMismatch FuncRef ExternRef)
Arrow from to <- maybeToEither TypeIndexOutOfRange $ asArrow <$> types !? sign
return $ (from ++ [Val I32]) ==> to
getInstrType _ Drop = do