summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLiu Liu <i@liuliu.me>2021-02-16 22:34:39 -0800
committerGitHub <noreply@github.com>2021-02-17 09:34:39 +0300
commit334c6be4964c3e0840105196405ac1419f158101 (patch)
treec22ff174a859b50199370840c2f36a8634893b75 /src
parent4174c10e7a4cac033fe1dc5e18437cd20d8bc3e6 (diff)
downloadflatbuffers-334c6be4964c3e0840105196405ac1419f158101.tar.gz
flatbuffers-334c6be4964c3e0840105196405ac1419f158101.tar.bz2
flatbuffers-334c6be4964c3e0840105196405ac1419f158101.zip
Fix a typo in Swift codegen (#6470)
* Fix a typo in Swift codegen * Fix code formatting.
Diffstat (limited to 'src')
-rw-r--r--src/idl_gen_swift.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/idl_gen_swift.cpp b/src/idl_gen_swift.cpp
index 4a86053a..7996b507 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");