From 067a275ce1e1a03e15a1ef910dc758f30938f0b1 Mon Sep 17 00:00:00 2001 From: SoCuul <63339559+SoCuul@users.noreply.github.com> Date: Mon, 27 Apr 2026 20:27:51 -0700 Subject: [PATCH] Pack booleans before integers, to avoid accidental mis-casting --- Sources/SwiftMsgPack/Encoder.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/SwiftMsgPack/Encoder.swift b/Sources/SwiftMsgPack/Encoder.swift index 5d04de2..a00997c 100644 --- a/Sources/SwiftMsgPack/Encoder.swift +++ b/Sources/SwiftMsgPack/Encoder.swift @@ -76,6 +76,11 @@ public extension Data { try self.pack(string: value_str) } + // BOOLEAN VALUES + else if let value_bool = obj as? Bool { + try self.pack(boolean: value_bool) + } + // UNSIGNED INT else if let value_u8 = obj as? UInt8 { // 8 BIT //try self.pack(signedInt: Int(value_u8)) @@ -133,11 +138,6 @@ public extension Data { else if let value_char = obj as? Character { try self.pack(string: String(value_char)) } - // BOOLEAN VALUES - else if let value_bool = obj as? Bool { - try self.pack(boolean: value_bool) - } - // ARRAY else if let value_array = obj as? [Any?] { try self.pack(array: value_array)