@@ -13,9 +13,7 @@ static void prim_fromTOML(EvalState & state, const PosIdx pos, Value ** args, Va
13
13
14
14
std::istringstream tomlStream (std::string{toml});
15
15
16
- std::function<void (Value &, toml::value)> visit;
17
-
18
- visit = [&](Value & v, toml::value t) {
16
+ auto visit = [&](auto & self, Value & v, toml::value t) -> void {
19
17
switch (t.type ()) {
20
18
case toml::value_t ::table: {
21
19
auto table = toml::get<toml::table>(t);
@@ -30,7 +28,7 @@ static void prim_fromTOML(EvalState & state, const PosIdx pos, Value ** args, Va
30
28
31
29
for (auto & elem : table) {
32
30
forceNoNullByte (elem.first );
33
- visit ( attrs.alloc (elem.first ), elem.second );
31
+ self (self, attrs.alloc (elem.first ), elem.second );
34
32
}
35
33
36
34
v.mkAttrs (attrs);
@@ -40,7 +38,7 @@ static void prim_fromTOML(EvalState & state, const PosIdx pos, Value ** args, Va
40
38
41
39
auto list = state.buildList (array.size ());
42
40
for (const auto & [n, v] : enumerate(list))
43
- visit ( *(v = state.allocValue ()), array[n]);
41
+ self (self, *(v = state.allocValue ()), array[n]);
44
42
v.mkList (list);
45
43
} break ;
46
44
case toml::value_t ::boolean:
@@ -81,7 +79,7 @@ static void prim_fromTOML(EvalState & state, const PosIdx pos, Value ** args, Va
81
79
};
82
80
83
81
try {
84
- visit (val, toml::parse (tomlStream, " fromTOML" /* the "filename" */ ));
82
+ visit (visit, val, toml::parse (tomlStream, " fromTOML" /* the "filename" */ ));
85
83
} catch (std::exception & e) { // TODO: toml::syntax_error
86
84
state.error <EvalError>(" while parsing TOML: %s" , e.what ()).atPos (pos).debugThrow ();
87
85
}
0 commit comments