fix elems validator
This commit is contained in:
@@ -56,7 +56,8 @@ runScript onAssertFail script = do
|
||||
("global_i32", globI32),
|
||||
("global_f32", globF32),
|
||||
("global_f64", globF64),
|
||||
("memory", Interpreter.HostMemory $ Struct.Limit 1 (Just 2))
|
||||
("memory", Interpreter.HostMemory $ Struct.Limit 1 (Just 2)),
|
||||
("table", Interpreter.HostTable $ Struct.Limit 10 (Just 20))
|
||||
]
|
||||
go script $ emptyState { store = st, moduleRegistery = Map.singleton "spectest" inst }
|
||||
where
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user