Browse Source

Env: Core function (get) should work on nil value

master
Riyyi 1 year ago
parent
commit
8aa540c4e5
  1. 7
      src/functions.cpp

7
src/functions.cpp

@ -662,6 +662,7 @@ ADD_FUNCTION(
return result;
});
// (assoc {:a 1 :b 2} :a 3 :c 1)
ADD_FUNCTION(
"assoc",
{
@ -698,11 +699,17 @@ ADD_FUNCTION(
return result;
});
// (get {:kw "value"} :kw)
ADD_FUNCTION(
"get",
{
CHECK_ARG_COUNT_AT_LEAST("get", nodes.size(), 1);
if (is<Constant>(nodes.front().get())
&& std::static_pointer_cast<Constant>(nodes.front())->state() == Constant::Nil) {
return makePtr<Constant>();
}
VALUE_CAST(hash_map, HashMap, nodes.front());
nodes.pop_front();

Loading…
Cancel
Save