Handle singleton records in erlang_to_fate #27

Merged
spivee merged 3 commits from singleton_records into master 2026-05-13 12:53:52 +09:00
Showing only changes of commit ed252b4c06 - Show all commits
+2 -2
View File
@@ -832,7 +832,7 @@ coerce_record_to_map(O, N, MemberTypes, Tuple) ->
correct_record_error_paths(Names, Errors) -> correct_record_error_paths(Names, Errors) ->
CorrectOne = fun({Error, [{record_element, N} | Path]}) -> CorrectOne = fun({Error, [{record_element, N} | Path]}) ->
FieldName = lists:nth(N + 1, Names), FieldName = lists:nth(N + 1, Names),
{Error, [{record_element, FieldName} | Path]} {Error, [{record_element, N, FieldName} | Path]}
end, end,
Corrected = lists:map(CorrectOne, Errors), Corrected = lists:map(CorrectOne, Errors),
{error, Corrected}. {error, Corrected}.
@@ -1169,7 +1169,7 @@ singleton_record_substitution_test() ->
check_roundtrip(HOutput, #{"it" => {123, 456}}, {tuple, {123, 456}}), check_roundtrip(HOutput, #{"it" => {123, 456}}, {tuple, {123, 456}}),
% Also check that records have accurate paths, since the implementation for % Also check that records have accurate paths, since the implementation for
% record error paths is a bit fiddly. % record error paths is a bit fiddly.
{error, [{{tuple_too_many_terms, _, _, _}, [{record_element, "it"}]}]} = fate_to_erlang(HOutput, {tuple, {1, 2, 3}}). {error, [{{tuple_too_many_terms, _, _, _}, [{record_element, 0, "it"}]}]} = fate_to_erlang(HOutput, {tuple, {1, 2, 3}}).
tuple_substitution_test() -> tuple_substitution_test() ->
Contract = " Contract = "