aboutsummaryrefslogtreecommitdiff
path: root/src/gleam_stdlib.erl
diff options
context:
space:
mode:
authorGiacomo Cavalieri <giacomo.cavalieri@icloud.com>2023-04-21 15:04:50 +0200
committerLouis Pilfold <louis@lpil.uk>2023-04-29 14:33:18 +0100
commit54b22b142d17f0fd893ec2465e53b92109aadb48 (patch)
treec7a6bba9e1c1f35e0285570cda7e4468eb9283b0 /src/gleam_stdlib.erl
parent8924398359342ad33e99d707a3c8a7fb44d99da0 (diff)
downloadgleam_stdlib-54b22b142d17f0fd893ec2465e53b92109aadb48.tar.gz
gleam_stdlib-54b22b142d17f0fd893ec2465e53b92109aadb48.zip
Fix `dynamic.field` behaviour
Diffstat (limited to 'src/gleam_stdlib.erl')
-rw-r--r--src/gleam_stdlib.erl10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/gleam_stdlib.erl b/src/gleam_stdlib.erl
index 33c9609..4c59893 100644
--- a/src/gleam_stdlib.erl
+++ b/src/gleam_stdlib.erl
@@ -78,12 +78,14 @@ decode_bool(Data) -> decode_error_msg(<<"Bool">>, Data).
decode_list(Data) when is_list(Data) -> {ok, Data};
decode_list(Data) -> decode_error_msg(<<"List">>, Data).
-decode_field(Data, Key) ->
+decode_field(Data, Key) when is_map(Data) ->
case Data of
- #{Key := Value} -> {ok, Value};
+ #{Key := Value} -> {ok, {ok, Value}};
_ ->
- decode_error(<<"field"/utf8>>, <<"nothing"/utf8>>)
- end.
+ {ok, decode_error(<<"field"/utf8>>, <<"nothing"/utf8>>)}
+ end;
+decode_field(Data, _) ->
+ decode_error_msg(<<"Map">>, Data).
size_of_tuple(Data) -> tuple_size(Data).