Skip to content

Commit b098410

Browse files
WasmParser: Move validation errors to the WasmKit module
1 parent a0beed0 commit b098410

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

Sources/WasmKit/Translator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2213,7 +2213,7 @@ extension FunctionType {
22132213
case let .funcType(typeIndex):
22142214
let typeIndex = Int(typeIndex)
22152215
guard typeIndex < typeSection.count else {
2216-
throw WasmParserError.invalidTypeSectionReference
2216+
throw ValidationError("type index out of bounds: accessed \(typeIndex), but only \(typeSection.count) types are defined")
22172217
}
22182218
let funcType = typeSection[typeIndex]
22192219
self.init(

Sources/WasmParser/WasmParser.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,6 @@ extension WasmParserError.Message {
307307

308308
@usableFromInline static let malformedIndirectCall = Self("Malformed indirect call")
309309

310-
static let invalidTypeSectionReference = Self("Invalid reference to a type section entry")
311-
312310
static func malformedDataSegmentKind(_ kind: UInt32) -> Self {
313311
Self("Malformed data segment kind: \(kind)")
314312
}
@@ -327,9 +325,6 @@ extension WasmParserError {
327325
public static var sectionOutOfOrder: Self {
328326
Self(.sectionOutOfOrder, offset: 0)
329327
}
330-
public static var invalidTypeSectionReference: Self {
331-
Self(.invalidTypeSectionReference, offset: 0)
332-
}
333328
public static func inconsistentFunctionAndCodeLength(functionCount: Int, codeCount: Int) -> Self {
334329
Self(.inconsistentFunctionAndCodeLength(functionCount: functionCount, codeCount: codeCount), offset: 0)
335330
}

0 commit comments

Comments
 (0)