From 334c6be4964c3e0840105196405ac1419f158101 Mon Sep 17 00:00:00 2001 From: Liu Liu Date: Tue, 16 Feb 2021 22:34:39 -0800 Subject: [PATCH] Fix a typo in Swift codegen (#6470) * Fix a typo in Swift codegen * Fix code formatting. --- src/idl_gen_swift.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/idl_gen_swift.cpp b/src/idl_gen_swift.cpp index 4a86053..7996b50 100644 --- a/src/idl_gen_swift.cpp +++ b/src/idl_gen_swift.cpp @@ -590,8 +590,9 @@ class SwiftGenerator : public BaseGenerator { if (IsStruct(field.value.type)) { auto create_struct = - "guard let pos = pos else { return };" - " fbb.create(struct: pos, position: {{TABLEOFFSET}}.{{OFFSET}}.p) }"; + "guard let {{VALUENAME}} = {{VALUENAME}} else { return };" + " fbb.create(struct: {{VALUENAME}}, position: " + "{{TABLEOFFSET}}.{{OFFSET}}.p) }"; code_ += type + "?" + builder_string + create_struct; /// Optional hard coded since structs are always optional create_func_header.push_back(name + ": " + type + "? = nil"); -- 2.7.4