about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/primops/fromTOML.cc
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-08-21T02·29+0100
committertazjin <mail@tazj.in>2020-08-21T03·55+0000
commit1443298657156107704b5d9fcfa7356ee8fa8789 (patch)
tree3c4009acabdc90799d11084dbe5df58f39b90beb /third_party/nix/src/libexpr/primops/fromTOML.cc
parent7edbe59c6c70cd085fc68c4317c3a71a40ac21e5 (diff)
style(tvix): Add missing braces in expressions r/1703
The previous clang-tidy invocation missed some header files, which has
now been rectified.

Change-Id: I31547754fbf52f439dc7aeefb08ab90bd50c4156
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1831
Reviewed-by: glittershark <grfn@gws.fyi>
Tested-by: BuildkiteCI
Diffstat (limited to 'third_party/nix/src/libexpr/primops/fromTOML.cc')
-rw-r--r--third_party/nix/src/libexpr/primops/fromTOML.cc26
1 files changed, 16 insertions, 10 deletions
diff --git a/third_party/nix/src/libexpr/primops/fromTOML.cc b/third_party/nix/src/libexpr/primops/fromTOML.cc
index 389ac080677a..e3d2a4940769 100644
--- a/third_party/nix/src/libexpr/primops/fromTOML.cc
+++ b/third_party/nix/src/libexpr/primops/fromTOML.cc
@@ -30,10 +30,12 @@ static void prim_fromTOML(EvalState& state, const Pos& pos, Value** args,
         if (auto i2 = i.second->as_table_array()) {
           size_t size2 = i2->get().size();
           state.mkList(v2, size2);
-          for (size_t j = 0; j < size2; ++j)
+          for (size_t j = 0; j < size2; ++j) {
             visit(*((*v2.list)[j] = state.allocValue()), i2->get()[j]);
-        } else
+          }
+        } else {
           visit(v2, i.second);
+        }
       }
     }
 
@@ -42,8 +44,9 @@ static void prim_fromTOML(EvalState& state, const Pos& pos, Value** args,
 
       state.mkList(v, size);
 
-      for (size_t i = 0; i < size; ++i)
+      for (size_t i = 0; i < size; ++i) {
         visit(*((*v.list)[i] = state.allocValue()), t2->get()[i]);
+      }
     }
 
     // Handle cases like 'a = [[{ a = true }]]', which IMHO should be
@@ -55,25 +58,28 @@ static void prim_fromTOML(EvalState& state, const Pos& pos, Value** args,
 
       state.mkList(v, size);
 
-      for (size_t j = 0; j < size; ++j)
+      for (size_t j = 0; j < size; ++j) {
         visit(*((*v.list)[j] = state.allocValue()), t2->get()[j]);
+      }
     }
 
     else if (t->is_value()) {
-      if (auto val = t->as<int64_t>())
+      if (auto val = t->as<int64_t>()) {
         mkInt(v, val->get());
-      else if (auto val = t->as<NixFloat>())
+      } else if (auto val = t->as<NixFloat>()) {
         mkFloat(v, val->get());
-      else if (auto val = t->as<bool>())
+      } else if (auto val = t->as<bool>()) {
         mkBool(v, val->get());
-      else if (auto val = t->as<std::string>())
+      } else if (auto val = t->as<std::string>()) {
         mkString(v, val->get());
-      else
+      } else {
         throw EvalError("unsupported value type in TOML");
+      }
     }
 
-    else
+    else {
       abort();
+    }
   };
 
   try {