fix elems validator

This commit is contained in:
Ilya Rezvov
2018-04-08 17:51:04 -07:00
parent 277cfad6ff
commit 6b376ee4cb
4 changed files with 6 additions and 4 deletions
+2 -1
View File
@@ -539,7 +539,8 @@ elemsShouldBeValid m@Module { elems, functions, tables, imports } =
then Valid
else IndexOutOfRange
in
let funsLength = fromIntegral $ length functions in
let funImports = filter isFuncImport imports in
let funsLength = fromIntegral $ length functions + length funImports in
let isFunsValid = foldMap (\i -> if i < funsLength then Valid else IndexOutOfRange) funs in
isIniterValid <> isFunsValid <> isTableIndexValid